Text correction

ABSTRACT

The present disclosure generally relates to text correction and generating text correction models. In an example process for text correction, text input is received. In response to receiving the text input, a text string corresponding to the text input is displayed. The text string is represented by a token sequence. The process determines whether an end of the token sequence corresponds to a text boundary. In accordance with a determination that the end of the token sequence corresponds to a text boundary, the process determines, based on a context state of the token sequence, one or more textual errors at one or more tokens of the token sequence. An error indication for a portion of the text string corresponding to the one or more tokens is displayed.

CROSS-REFERENCE TO RELATED APPLICATION

This application claims priority from U.S. Provisional Ser. No. 62/679,511, filed on Jun. 1, 2018, entitled TEXT CORRECTION, which is hereby incorporated by reference in its entirety for all purposes.

FIELD

The present disclosure relates generally to text correction, and more specifically to techniques for text correction using predictive labeling.

BACKGROUND

Users of computing equipment such as computers and handheld devices can enter text using, for example, a keyboard. The text entered by users can contain errors. Error correction capabilities can be provided in many devices to assist a user in accurately entering text. Some error correction techniques can be implemented using a dictionary of known words. When a user enters a character sequence that does not correspond to a known word in the dictionary, the character sequence can be corrected. Although such techniques can be effective for correcting spelling errors, other types of textual errors can be difficult to correct. For example, textual errors associated with homophone confusion (e.g., hear/here or to/too), wrong usage of apostrophe (e.g., it's vs. its), subject-verb disagreement (e.g., everyone at the meeting are responsible), or diacritic confusions (e.g., tu vs. tú) can be difficult to correct using only a dictionary of known words.

BRIEF SUMMARY

The present disclosure generally relates to text correction. In an example process for text correction, text input is received. In response to receiving the text input, a text string corresponding to the text input is displayed. The text string is represented by a token sequence. The process determines whether an end of the token sequence corresponds to a text boundary. In accordance with a determination that the end of the token sequence corresponds to a text boundary, the process determines, based on a context state of the token sequence, one or more textual errors at one or more tokens of the token sequence. An error indication for a portion of the text string corresponding to the one or more tokens is displayed.

The present disclosure further relates to generating a text correction model. In an example process for generating a text correction model, a plurality of word pairs are obtained. Each word pair of the plurality of word pairs includes a positive word example and a negative word example. A corpus of text is obtained. Based on the obtained corpus of text and the plurality of word pairs, an error-induced corpus of text is generated. The error-induced corpus of text includes a plurality of textual errors corresponding to at least a portion of the plurality of word pairs. Training data is generated from the corpus of text and the error-induced corpus of text. A text correction model is trained using the training data. The trained text correction model is applied to a text string to produce corrected text.

DESCRIPTION OF THE FIGURES

For a better understanding of the various described embodiments, reference should be made to the Description of Embodiments below, in conjunction with the following drawings in which like reference numerals refer to corresponding parts throughout the figures.

FIG. 1A is a block diagram illustrating a portable multifunction device with a touch-sensitive display in accordance with some embodiments.

FIG. 1B is a block diagram illustrating exemplary components for event handling in accordance with some embodiments.

FIG. 2 illustrates a portable multifunction device having a touch screen in accordance with some embodiments.

FIG. 3 is a block diagram of an exemplary multifunction device with a display and a touch-sensitive surface in accordance with some embodiments.

FIG. 4A illustrates an exemplary user interface for a menu of applications on a portable multifunction device in accordance with some embodiments.

FIG. 4B illustrates an exemplary user interface for a multifunction device with a touch-sensitive surface that is separate from the display in accordance with some embodiments.

FIG. 5A illustrates a personal electronic device in accordance with some embodiments.

FIG. 5B is a block diagram illustrating a personal electronic device in accordance with some embodiments.

FIG. 6 illustrates a block diagram of a text correction module in accordance with some embodiments.

FIG. 7 illustrates a text correction model in accordance with some embodiments.

FIG. 8 illustrates a block diagram of a model generation module in accordance with some embodiments.

FIG. 9 illustrates a table with various types of textual errors and specific examples of the types of textual errors in accordance with some embodiments.

FIGS. 10A-10D illustrate an electronic device displaying user interfaces for performing automatic text correction in accordance with some embodiments.

FIG. 11 is a flow diagram illustrating a process for text correction using an electronic device in accordance with some embodiments.

FIG. 12 is a flow diagram illustrating a process for generating a text correction model in accordance with some embodiments.

DESCRIPTION OF EMBODIMENTS

The following description sets forth exemplary methods, parameters, and the like. It should be recognized, however, that such description is not intended as a limitation on the scope of the present disclosure but is instead provided as a description of exemplary embodiments.

The present disclosure relates to techniques for efficient and accurate automatic text correction. As discussed above, existing text correction techniques can be inadequate for efficiently and accurately detecting and correcting textual errors associated with improper context. For example, it can be difficult to detect textual errors in sentences such as “It's over their by the window” or “My cat couldn't start and I had to call the tow truck.”

One exemplary approach to text correction utilizes deterministic (e.g., rule-based) techniques where hand-crafted rules and grammars are applied to recognize and correct textual errors in a given text. For example, a hand-crafted rule can specify that the word “their” in a sentence should be followed by a noun. Thus, if the word “their” in a sentence is not followed by a noun, the text correction mechanism applying this rule would recognize that the word “their” in the sentence is a textual error and would suggest that the word be substituted with the correct word “there.” However, one problem with deterministic approaches to text correction is that hand-crafted rules and grammars can be difficult to scale or maintain. In particular, a group of language experts would be needed to generate and maintain hand-crafted rules and grammars for correcting targeted types of textual errors in each language. Given the large number of languages in the world as well as the large number of possible textual errors in each language, deterministic approaches can be difficult to scale and maintain for a global text correction platform.

Statistical approaches to text correction can be advantageous over deterministic approaches due to greater accuracy and tractability. Such approaches implement probabilistic rather than deterministic systems. For example, instead of utilizing language experts to generate and maintain specific rules for each type of textual error in each language, statistical approaches utilize training data (e.g., labeled text based on pairs of positive/negative examples) to build and/or update statistical models that perform text correction. For example, a statistical model can be trained to recognize and correct textual errors in a given text.

One example of a statistical model is the n-gram language model, which considers a window of n words/tokens to identify potential textual errors. Although n-gram language models can account for context when identifying potential textual errors, the context is often limited to immediate prior words within the n-word window. For example, a 3-gram language model would only evaluate a word in the context of the two immediately prior words. Therefore, given the phrase “It's over their,” a 3-gram language model would be able to recognize the textual error associated with the word “their” by evaluating the word in the context of the two immediately prior words “It's over.” However, a 3-gram language model would not be able to recognize the textual error associated with the word “cat” in the sentence “My cat couldn't start and I had to call the tow truck” because it requires consideration of more distant context (“I had to call the tow truck”) located after the word “cat.” Although n-gram language models can be generated to evaluate a larger window of n-words (e.g., 10-gram or 20-gram), such models require large amounts of data to train and require significant amounts of computer resources (e.g., processing speed, memory, and power) to store and operate. Such large models would not be suitable for implementation in portable electronic devices that have limited processing power, memory, and battery life.

Another example of a statistical model is a machine-learned model that can directly predict corrected text from a given text containing textual errors. For example, a machine-learned model can predict corrected text based on an output token vocabulary that is 10 k-100 k in size. However, given the large number of possible predicted outputs, the predictions generated by such a model can be relatively unconstrained, which can result in egregious errors that fundamentally change the meaning of the text that is corrected. Such unconstrained predictions can be particularly problematic for text that is sparsely represented in the training data. To address issues of sparseness, a large set of training data can be required to build an accurate model. The resultant model would thus be very large and require significant amounts of computer resources (e.g., processing speed, memory, and power) to store and operate.

The text correction techniques presented herein address the above-described challenges. In particular, the text correction techniques presented herein consider the broader context of a token sequence to identify textual errors. For example, rather than analyzing small fragments of text (e.g., 3-word window), a token sequence is analyzed as a complete linguistic unit (e.g., sentence, paragraph, document) to identify textual errors. In some examples, both the forward and backward contexts of each token are analyzed to determine whether a token in the token sequence corresponds to a textual error. For example, as described in greater detail below, a trained bidirectional long short-term memory (LSTM) recurrent neural network (RNN) model can be implemented to perform automatic text correction. Using such a model, the sentence “My cat couldn't start and I had to call the tow truck” can be analyzed as a whole where both the prior context (e.g., “My”) and the subsequent context (e.g., “couldn't start and I had to call the tow truck”) are considered in determining that the word “cat” corresponds to a textual error. By considering the context of a linguistic unit as a whole, textual errors can be recognized and corrected more accurately and efficiently.

Moreover, the text correction techniques presented herein leverage a limited number of rules and grammars to cast text correction as a labeling problem. For example, rather than training a statistical model to directly predict corrected text from a token sequence, a statistical model is trained to predict a sequence of labels to assign to the token sequence. Each assigned label is selected from a limited number of possible labels (e.g., less than 100, 200, or 500 unique labels). Each assigned label specifies whether the respective token contains a textual error and if so, the type of textual error associated with the token. Based on the sequence of labels, edit operation(s) can be applied to the token sequence to correct the textual error(s). By casting text correction as a labeling problem, the statistical model is constrained to a limited number of possible edit operations. This limits the degree of any error committed by the model. In addition, casting text correction as a labeling problem simplifies the underlying statistical model, which can reduce the amount of training data required to achieve an accurate model. Because less training data is required, the model can be generated faster and can require less computer resources to store and operate (e.g., suitable for implementation of portable electronic devices). This, in turn, can improve the battery life of the device performing text correction.

The present disclosure further relates to efficient and scalable techniques for training a text correction model. In conventional training techniques, it can be difficult to obtain training data with labeled examples. For example, obtaining sentences with known textual errors (e.g., confused homophones, missing apostrophe, subject-verb disagreement, incorrect use of diacritic, etc.) can be difficult without infringing on the privacy of the user. As described in greater detail below, an error-inducing mechanism is generated to automatically induce errors in a corpus of text. The error-inducing mechanism includes, for example, rules and/or models corresponding to a plurality of word pairs identified by a linguist. Each word pair of the plurality of word pairs includes a positive example and a negative example of a respective textual error. By applying the rules and/or models to a substantially error-free corpus of text, the error-inducing mechanism automatically generates an error-induced corpus of text containing a plurality of textual errors. The plurality of textual errors correspond to at least a portion of the plurality of word pairs. Training data is then generated from the corpus of text and the error-induced corpus of text. The generated training data is then used to train a statistical text correction model (e.g., via machine-learning). The described techniques of automatically generating training data can be advantageous because no externally labelled data or manual annotation is required to generate the text correction model. In addition, the technique can be easily scalable where the plurality of word pairs can be expanded and corresponding training data can be quickly generated to update the model. In this way, text correction models can be more quickly and efficiently generated and updated.

Although the following description uses terms “first,” “second,” etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, a first touch could be termed a second touch, and, similarly, a second touch could be termed a first touch, without departing from the scope of the various described embodiments. The first touch and the second touch are both touches, but they are not the same touch.

The terminology used in the description of the various described embodiments herein is for the purpose of describing particular embodiments only and is not intended to be limiting. As used in the description of the various described embodiments and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term “and/or” as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. It will be further understood that the terms “includes,” “including,” “comprises,” and/or “comprising,” when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.

The term “if” is, optionally, construed to mean “when” or “upon” or “in response to determining” or “in response to detecting,” depending on the context. Similarly, the phrase “if it is determined” or “if [a stated condition or event] is detected” is, optionally, construed to mean “upon determining” or “in response to determining” or “upon detecting [the stated condition or event]” or “in response to detecting [the stated condition or event],” depending on the context.

Embodiments of electronic devices, user interfaces for such devices, and associated processes for using such devices are described. In some embodiments, the device is a portable communications device, such as a mobile telephone, that also contains other functions, such as PDA and/or music player functions. Exemplary embodiments of portable multifunction devices include, without limitation, the iPhone®, iPod Touch®, and iPad® devices from Apple Inc. of Cupertino, Calif. Other portable electronic devices, such as laptops or tablet computers with touch-sensitive surfaces (e.g., touch screen displays and/or touchpads), are, optionally, used. It should also be understood that, in some embodiments, the device is not a portable communications device, but is a desktop computer with a touch-sensitive surface (e.g., a touch screen display and/or a touchpad).

In the discussion that follows, an electronic device that includes a display and a touch-sensitive surface is described. It should be understood, however, that the electronic device optionally includes one or more other physical user-interface devices, such as a physical keyboard, a mouse, and/or a joystick.

The device typically supports a variety of applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disk authoring application, a spreadsheet application, a gaming application, a telephone application, a video conferencing application, an e-mail application, an instant messaging application, a workout support application, a photo management application, a digital camera application, a digital video camera application, a web browsing application, a digital music player application, and/or a digital video player application.

The various applications that are executed on the device optionally use at least one common physical user-interface device, such as the touch-sensitive surface. One or more functions of the touch-sensitive surface as well as corresponding information displayed on the device are, optionally, adjusted and/or varied from one application to the next and/or within a respective application. In this way, a common physical architecture (such as the touch-sensitive surface) of the device optionally supports the variety of applications with user interfaces that are intuitive and transparent to the user.

Attention is now directed toward embodiments of portable devices with touch-sensitive displays. FIG. 1A is a block diagram illustrating portable multifunction device 100 with touch-sensitive display system 112 in accordance with some embodiments. Touch-sensitive display 112 is sometimes called a “touch screen” for convenience and is sometimes known as or called a “touch-sensitive display system.” Device 100 includes memory 102 (which optionally includes one or more computer-readable storage mediums), memory controller 122, one or more processing units (CPUs) 120, peripherals interface 118, RF circuitry 108, audio circuitry 110, speaker 111, microphone 113, input/output (I/O) subsystem 106, other input control devices 116, and external port 124. Device 100 optionally includes one or more optical sensors 164. Device 100 optionally includes one or more contact intensity sensors 165 for detecting intensity of contacts on device 100 (e.g., a touch-sensitive surface such as touch-sensitive display system 112 of device 100). Device 100 optionally includes one or more tactile output generators 167 for generating tactile outputs on device 100 (e.g., generating tactile outputs on a touch-sensitive surface such as touch-sensitive display system 112 of device 100 or touchpad 355 of device 300). These components optionally communicate over one or more communication buses or signal lines 103.

As used in the specification and claims, the term “intensity” of a contact on a touch-sensitive surface refers to the force or pressure (force per unit area) of a contact (e.g., a finger contact) on the touch-sensitive surface, or to a substitute (proxy) for the force or pressure of a contact on the touch-sensitive surface. The intensity of a contact has a range of values that includes at least four distinct values and more typically includes hundreds of distinct values (e.g., at least 256). Intensity of a contact is, optionally, determined (or measured) using various approaches and various sensors or combinations of sensors. For example, one or more force sensors underneath or adjacent to the touch-sensitive surface are, optionally, used to measure force at various points on the touch-sensitive surface. In some implementations, force measurements from multiple force sensors are combined (e.g., a weighted average) to determine an estimated force of a contact. Similarly, a pressure-sensitive tip of a stylus is, optionally, used to determine a pressure of the stylus on the touch-sensitive surface. Alternatively, the size of the contact area detected on the touch-sensitive surface and/or changes thereto, the capacitance of the touch-sensitive surface proximate to the contact and/or changes thereto, and/or the resistance of the touch-sensitive surface proximate to the contact and/or changes thereto are, optionally, used as a substitute for the force or pressure of the contact on the touch-sensitive surface. In some implementations, the substitute measurements for contact force or pressure are used directly to determine whether an intensity threshold has been exceeded (e.g., the intensity threshold is described in units corresponding to the substitute measurements). In some implementations, the substitute measurements for contact force or pressure are converted to an estimated force or pressure, and the estimated force or pressure is used to determine whether an intensity threshold has been exceeded (e.g., the intensity threshold is a pressure threshold measured in units of pressure). Using the intensity of a contact as an attribute of a user input allows for user access to additional device functionality that may otherwise not be accessible by the user on a reduced-size device with limited real estate for displaying affordances (e.g., on a touch-sensitive display) and/or receiving user input (e.g., via a touch-sensitive display, a touch-sensitive surface, or a physical/mechanical control such as a knob or a button).

As used in the specification and claims, the term “tactile output” refers to physical displacement of a device relative to a previous position of the device, physical displacement of a component (e.g., a touch-sensitive surface) of a device relative to another component (e.g., housing) of the device, or displacement of the component relative to a center of mass of the device that will be detected by a user with the user's sense of touch. For example, in situations where the device or the component of the device is in contact with a surface of a user that is sensitive to touch (e.g., a finger, palm, or other part of a user's hand), the tactile output generated by the physical displacement will be interpreted by the user as a tactile sensation corresponding to a perceived change in physical characteristics of the device or the component of the device. For example, movement of a touch-sensitive surface (e.g., a touch-sensitive display or trackpad) is, optionally, interpreted by the user as a “down click” or “up click” of a physical actuator button. In some cases, a user will feel a tactile sensation such as an “down click” or “up click” even when there is no movement of a physical actuator button associated with the touch-sensitive surface that is physically pressed (e.g., displaced) by the user's movements. As another example, movement of the touch-sensitive surface is, optionally, interpreted or sensed by the user as “roughness” of the touch-sensitive surface, even when there is no change in smoothness of the touch-sensitive surface. While such interpretations of touch by a user will be subject to the individualized sensory perceptions of the user, there are many sensory perceptions of touch that are common to a large majority of users. Thus, when a tactile output is described as corresponding to a particular sensory perception of a user (e.g., an “up click,” a “down click,” “roughness”), unless otherwise stated, the generated tactile output corresponds to physical displacement of the device or a component thereof that will generate the described sensory perception for a typical (or average) user.

It should be appreciated that device 100 is only one example of a portable multifunction device, and that device 100 optionally has more or fewer components than shown, optionally combines two or more components, or optionally has a different configuration or arrangement of the components. The various components shown in FIG. 1A are implemented in hardware, software, or a combination of both hardware and software, including one or more signal processing and/or application-specific integrated circuits.

Memory 102 optionally includes high-speed random access memory and optionally also includes non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices, or other non-volatile solid-state memory devices. Memory controller 122 optionally controls access to memory 102 by other components of device 100.

Peripherals interface 118 can be used to couple input and output peripherals of the device to CPU 120 and memory 102. The one or more processors 120 run or execute various software programs and/or sets of instructions stored in memory 102 to perform various functions for device 100 and to process data. In some embodiments, peripherals interface 118, CPU 120, and memory controller 122 are, optionally, implemented on a single chip, such as chip 104. In some other embodiments, they are, optionally, implemented on separate chips.

RF (radio frequency) circuitry 108 receives and sends RF signals, also called electromagnetic signals. RF circuitry 108 converts electrical signals to/from electromagnetic signals and communicates with communications networks and other communications devices via the electromagnetic signals. RF circuitry 108 optionally includes well-known circuitry for performing these functions, including but not limited to an antenna system, an RE transceiver, one or more amplifiers, a tuner, one or more oscillators, a digital signal processor, a CODEC chipset, a subscriber identity module (SIM) card, memory, and so forth. RE circuitry 108 optionally communicates with networks, such as the Internet, also referred to as the World Wide Web (WWW), an intranet and/or a wireless network, such as a cellular telephone network, a wireless local area network (LAN) and/or a metropolitan area network (MAN), and other devices by wireless communication. The RF circuitry 108 optionally includes well-known circuitry for detecting near field communication (NFC) fields, such as by a short-range communication radio. The wireless communication optionally uses any of a plurality of communications standards, protocols, and technologies, including but not limited to Global System for Mobile Communications (GSM), Enhanced Data GSM Environment (EDGE), high-speed downlink packet access (HSDPA), high-speed uplink packet access (HSUPA), Evolution, Data-Only (EV-DO), HSPA, HSPA+, Dual-Cell HSPA (DC-HSPDA), long term evolution (LTE), near field communication (NFC), wideband code division multiple access (W-CDMA), code division multiple access (CDMA), time division multiple access (TDMA), Bluetooth, Bluetooth Low Energy (BTLE), Wireless Fidelity (Wi-Fi) (e.g., IEEE 802.11a, IEEE 802.11b, IEEE 802.11g, IEEE 802.11n, and/or IEEE 802.11ac), voice over Internet Protocol (VOIP), Wi-MAX, a protocol for e-mail (e.g., Internet message access protocol (IMAP) and/or post office protocol (POP)), instant messaging (e.g., extensible messaging and presence protocol (XMPP), Session Initiation Protocol for Instant Messaging and Presence Leveraging Extensions (SIMPLE), Instant Messaging and Presence Service (IMPS)), and/or Short Message Service (SMS), or any other suitable communication protocol, including communication protocols not yet developed as of the filing date of this document.

Audio circuitry 110, speaker 111, and microphone 113 provide an audio interface between a user and device 100. Audio circuitry 110 receives audio data from peripherals interface 118, converts the audio data to an electrical signal, and transmits the electrical signal to speaker 111. Speaker 111 converts the electrical signal to human-audible sound waves. Audio circuitry 110 also receives electrical signals converted by microphone 113 from sound waves. Audio circuitry 110 converts the electrical signal to audio data and transmits the audio data to peripherals interface 118 for processing. Audio data is, optionally, retrieved from and/or transmitted to memory 102 and/or RF circuitry 108 by peripherals interface 118. In some embodiments, audio circuitry 110 also includes a headset jack (e.g., 212, FIG. 2). The headset jack provides an interface between audio circuitry 110 and removable audio input/output peripherals, such as output-only headphones or a headset with both output (e.g., a headphone for one or both ears) and input (e.g., a microphone).

I/O subsystem 106 couples input/output peripherals on device 100, such as touch screen 112 and other input control devices 116, to peripherals interface 118. I/O subsystem 106 optionally includes display controller 156, optical sensor controller 158, intensity sensor controller 159, haptic feedback controller 161, and one or more input controllers 160 for other input or control devices. The one or more input controllers 160 receive/send electrical signals from/to other input control devices 116. The other input control devices 116 optionally include physical buttons (e.g., push buttons, rocker buttons, etc.), dials, slider switches, joysticks, click wheels, and so forth. In some alternate embodiments, input controller(s) 160 are, optionally, coupled to any (or none) of the following: a keyboard, an infrared port, a USB port, and a pointer device such as a mouse. The one or more buttons (e.g., 208, FIG. 2) optionally include an up/down button for volume control of speaker 111 and/or microphone 113. The one or more buttons optionally include a push button (e.g., 206, FIG. 2).

A quick press of the push button optionally disengages a lock of touch screen 112 or optionally begins a process that uses gestures on the touch screen to unlock the device, as described in U.S. patent application Ser. No. 11/322,549, “Unlocking a Device by Performing Gestures on an Unlock Image,” filed Dec. 23, 2005, U.S. Pat. No. 7,657,849, which is hereby incorporated by reference in its entirety. A longer press of the push button (e.g., 206) optionally turns power to device 100 on or off. The functionality of one or more of the buttons are, optionally, user-customizable. Touch screen 112 is used to implement virtual or soft buttons and one or more soft keyboards.

Touch-sensitive display 112 provides an input interface and an output interface between the device and a user. Display controller 156 receives and/or sends electrical signals from/to touch screen 112. Touch screen 112 displays visual output to the user. The visual output optionally includes graphics, text, icons, video, and any combination thereof (collectively termed “graphics”). In some embodiments, some or all of the visual output optionally corresponds to user-interface objects.

Touch screen 112 has a touch-sensitive surface, sensor, or set of sensors that accepts input from the user based on haptic and/or tactile contact. Touch screen 112 and display controller 156 (along with any associated modules and/or sets of instructions in memory 102) detect contact (and any movement or breaking of the contact) on touch screen 112 and convert the detected contact into interaction with user-interface objects (e.g., one or more soft keys, icons, web pages, or images) that are displayed on touch screen 112. In an exemplary embodiment, a point of contact between touch screen 112 and the user corresponds to a finger of the user.

Touch screen 112 optionally uses LCD (liquid crystal display) technology, LPD (light emitting polymer display) technology, or LED (light emitting diode) technology, although other display technologies are used in other embodiments. Touch screen 112 and display controller 156 optionally detect contact and any movement or breaking thereof using any of a plurality of touch sensing technologies now known or later developed, including but not limited to capacitive, resistive, infrared, and surface acoustic wave technologies, as well as other proximity sensor arrays or other elements for determining one or more points of contact with touch screen 112. In an exemplary embodiment, projected mutual capacitance sensing technology is used, such as that found in the iPhone® and iPod Touch® from Apple Inc. of Cupertino, Calif.

A touch-sensitive display in some embodiments of touch screen 112 is, optionally, analogous to the multi-touch sensitive touchpads described in the following U.S. Pat. No. 6,323,846 (Westerman et al.), U.S. Pat. No. 6,570,557 (Westerman et al.), and/or U.S. Pat. No. 6,677,932 (Westerman), and/or U.S. Patent Publication 2002/0015024A1, each of which is hereby incorporated by reference in its entirety. However, touch screen 112 displays visual output from device 100, whereas touch-sensitive touchpads do not provide visual output.

A touch-sensitive display in some embodiments of touch screen 112 is described in the following applications: (1) U.S. patent application Ser. No. 11/381,313, “Multipoint Touch Surface Controller,” filed May 2, 2006; (2) U.S. patent application Ser. No. 10/840,862, “Multipoint Touchscreen,” filed May 6, 2004; (3) U.S. patent application Ser. No. 10/903,964, “Gestures For Touch Sensitive Input Devices,” filed Jul. 30, 2004; (4) U.S. patent application Ser. No. 11/048,264, “Gestures For Touch Sensitive input Devices,” filed Jan. 31, 2005; (5) U.S. patent application Ser. No. 11/038,590, “Mode-Based Graphical User Interfaces For Touch Sensitive Input Devices,” filed Jan. 18, 2005; (6) U.S. patent application Ser. No. 11/228,758, “Virtual Input Device Placement On A Touch Screen User Interface,” filed Sep. 16, 2005; (7) U.S. patent application Ser. No. 11/228,700, “Operation Of A Computer With A Touch Screen Interface,” filed Sep. 16, 2005; (8) U.S. patent application Ser. No. 11/228,737, “Activating Virtual Keys Of A Touch-Screen Virtual Keyboard,” filed Sep. 16, 2005; and (9) U.S. patent application Ser. No. 11/367,749, “Multi-Functional Hand-Held Device,” filed Mar. 3, 2006. All of these applications are incorporated by reference herein in their entirety.

Touch screen 112 optionally has a video resolution in excess of 100 dpi. In some embodiments, the touch screen has a video resolution of approximately 160 dpi. The user optionally makes contact with touch screen 112 using any suitable object or appendage, such as a stylus, a finger, and so forth. In some embodiments, the user interface is designed to work primarily with finger-based contacts and gestures, which can be less precise than stylus-based input due to the larger area of contact of a finger on the touch screen. In some embodiments, the device translates the rough finger-based input into a precise pointer/cursor position or command for performing the actions desired by the user.

In some embodiments, in addition to the touch screen, device 100 optionally includes a touchpad (not shown) for activating or deactivating particular functions. In some embodiments, the touchpad is a touch-sensitive area of the device that, unlike the touch screen, does not display visual output. The touchpad is, optionally, a touch-sensitive surface that is separate from touch screen 112 or an extension of the touch-sensitive surface formed by the touch screen.

Device 100 also includes power system 162 for powering the various components. Power system 162 optionally includes a power management system, one or more power sources (e.g., battery, alternating current (AC)), a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator (e.g., a light-emitting diode (LED)) and any other components associated with the generation, management and distribution of power in portable devices.

Device 100 optionally also includes one or more optical sensors 164. FIG. 1A shows an optical sensor coupled to optical sensor controller 158 in I/O subsystem 106. Optical sensor 164 optionally includes charge-coupled device (CCD) or complementary metal-oxide semiconductor (CMOS) phototransistors. Optical sensor 164 receives light from the environment, projected through one or more lenses, and converts the light to data representing an image. In conjunction with imaging module 143 (also called a camera module), optical sensor 164 optionally captures still images or video. In some embodiments, an optical sensor is located on the back of device 100, opposite touch screen display 112 on the front of the device so that the touch screen display is enabled for use as a viewfinder for still and/or video image acquisition. In some embodiments, an optical sensor is located on the front of the device so that the user's image is, optionally, obtained for video conferencing while the user views the other video conference participants on the touch screen display. In some embodiments, the position of optical sensor 164 can be changed by the user (e.g., by rotating the lens and the sensor in the device housing) so that a single optical sensor 164 is used along with the touch screen display for both video conferencing and still and/or video image acquisition.

Device 100 optionally also includes one or more contact intensity sensors 165. FIG. 1A shows a contact intensity sensor coupled to intensity sensor controller 159 in I/O subsystem 106. Contact intensity sensor 165 optionally includes one or more piezoresistive strain gauges, capacitive force sensors, electric force sensors, piezoelectric force sensors, optical force sensors, capacitive touch-sensitive surfaces, or other intensity sensors (e.g., sensors used to measure the force (or pressure) of a contact on a touch-sensitive surface). Contact intensity sensor 165 receives contact intensity information (e.g., pressure information or a proxy for pressure information) from the environment. In some embodiments, at least one contact intensity sensor is collocated with, or proximate to, a touch-sensitive surface (e.g., touch-sensitive display system 112). In some embodiments, at least one contact intensity sensor is located on the back of device 100, opposite touch screen display 112, which is located on the front of device 100.

Device 100 optionally also includes one or more proximity sensors 166. FIG. 1A shows proximity sensor 166 coupled to peripherals interface 118. Alternately, proximity sensor 166 is, optionally, coupled to input controller 160 in I/O subsystem 106. Proximity sensor 166 optionally performs as described in U.S. patent application Ser. No. 11/241,839, “Proximity Detector In Handheld Device”; U.S. patent application Ser. No. 11/240,788, “Proximity Detector In Handheld Device”; U.S. patent application Ser. No. 11/620,702, “Using Ambient Light Sensor To Augment Proximity Sensor Output”; U.S. patent application Ser. No. 11/586,862, “Automated Response To And Sensing Of User Activity In Portable Devices”; and U.S. patent application Ser. No. 11/638,251, “Methods And Systems For Automatic Configuration Of Peripherals,” which are hereby incorporated by reference in their entirety. In some embodiments, the proximity sensor turns off and disables touch screen 112 when the multifunction device is placed near the user's ear (e.g., when the user is making a phone call).

Device 100 optionally also includes one or more tactile output generators 167. FIG. 1A shows a tactile output generator coupled to haptic feedback controller 161 in I/O subsystem 106. Tactile output generator 167 optionally includes one or more electroacoustic devices such as speakers or other audio components and/or electromechanical devices that convert energy into linear motion such as a motor, solenoid, electroactive polymer, piezoelectric actuator, electrostatic actuator, or other tactile output generating component (e.g., a component that converts electrical signals into tactile outputs on the device). Contact intensity sensor 165 receives tactile feedback generation instructions from haptic feedback module 133 and generates tactile outputs on device 100 that are capable of being sensed by a user of device 100. In some embodiments, at least one tactile output generator is collocated with, or proximate to, a touch-sensitive surface (e.g., touch-sensitive display system 112) and, optionally, generates a tactile output by moving the touch-sensitive surface vertically (e.g., in/out of a surface of device 100) or laterally (e.g., back and forth in the same plane as a surface of device 100). In some embodiments, at least one tactile output generator sensor is located on the back of device 100, opposite touch screen display 112, which is located on the front of device 100.

Device 100 optionally also includes one or more accelerometers 168. FIG. 1A shows accelerometer 168 coupled to peripherals interface 118. Alternately, accelerometer 168 is, optionally, coupled to an input controller 160 in I/O subsystem 106. Accelerometer 168 optionally performs as described in U.S. Patent Publication No. 20050190059, “Acceleration-based Theft Detection System for Portable Electronic Devices,” and U.S. Patent Publication No. 20060017692, “Methods And Apparatuses For Operating A Portable Device Based On An Accelerometer,” both of which are incorporated by reference herein in their entirety. In some embodiments, information is displayed on the touch screen display in a portrait view or a landscape view based on an analysis of data received from the one or more accelerometers. Device 100 optionally includes, in addition to accelerometer(s) 168, a magnetometer (not shown and a GPS (or GLONASS or other global navigation system) receiver (not shown) for obtaining information concerning the location and orientation (e.g., portrait or landscape) of device 100.

In some embodiments, the software components stored in memory 102 include operating system 126, communication module (or set of instructions) 128, contact/motion module (or set of instructions) 130, graphics module (or set of instructions) 132, text input module (or set of instructions) 134, Global Positioning System (GPS) module (or set of instructions) 135, and applications (or sets of instructions) 136. Furthermore, in some embodiments, memory 102 (FIG. 1A) or 370 (FIG. 3) stores device/global internal state 157, as shown in FIGS. 1A and 3. Device/global internal state 157 includes one or more of: active application state, indicating which applications, if any, are currently active; display state, indicating what applications, views or other information occupy various regions of touch screen display 112; sensor state, including information obtained from the device's various sensors and input control devices 116; and location information concerning the device's location and/or attitude.

Operating system 126 (e.g., Darwin, RTXC, LINUX, UNIX, OS X, iOS, WINDOWS, or an embedded operating system such as VxWorks) includes various software components and/or drivers for controlling and managing general system tasks (e.g., memory management, storage device control, power management, etc.) and facilitates communication between various hardware and software components.

Communication module 128 facilitates communication with other devices over one or more external ports 124 and also includes various software components for handling data received by RF circuitry 108 and/or external port 124. External port 124 (e.g., Universal Serial Bus (USB), FIREWIRE, etc.) is adapted for coupling directly to other devices or indirectly over a network (e.g., the Internet, wireless LAN, etc.). In some embodiments, the external port is a multi-pin (e.g., 30-pin) connector that is the same as, or similar to and/or compatible with, the 30-pin connector used on iPod® (trademark of Apple Inc.) devices.

Contact/motion module 130 optionally detects contact with touch screen 112. (in conjunction with display controller 156) and other touch-sensitive devices (e.g., a touchpad or physical click wheel). Contact/motion module 130 includes various software components for performing various operations related to detection of contact, such as determining if contact has occurred (e.g., detecting a finger-down event), determining an intensity of the contact (e.g., the force or pressure of the contact or a substitute for the force or pressure of the contact), determining if there is movement of the contact and tracking the movement across the touch-sensitive surface (e.g., detecting one or more finger-dragging events), and determining if the contact has ceased (e.g., detecting a finger-up event or a break in contact). Contact/motion module 130 receives contact data from the touch-sensitive surface. Determining movement of the point of contact, which is represented by a series of contact data, optionally includes determining speed (magnitude), velocity (magnitude and direction), and/or an acceleration (a change in magnitude and/or direction) of the point of contact. These operations are, optionally, applied to single contacts (e.g., one finger contacts) or to multiple simultaneous contacts (e.g., “multitouch”/multiple finger contacts). In some embodiments, contact/motion module 130 and display controller 156 detect contact on a touchpad.

In some embodiments, contact/motion module 130 uses a set of one or more intensity thresholds to determine whether an operation has been performed by a user (e.g., to determine whether a user has “clicked” on an icon). In some embodiments, at least a subset of the intensity thresholds are determined in accordance with software parameters (e.g., the intensity thresholds are not determined by the activation thresholds of particular physical actuators and can be adjusted without changing the physical hardware of device 100). For example, a mouse “click” threshold of a trackpad or touch screen display can be set to any of a large range of predefined threshold values without changing the trackpad or touch screen display hardware. Additionally, in some implementations, a user of the device is provided with software settings for adjusting one or more of the set of intensity thresholds (e.g., by adjusting individual intensity thresholds and/or by adjusting a plurality of intensity thresholds at once with a system-level click “intensity” parameter).

Contact/motion module 130 optionally detects a gesture input by a user. Different gestures on the touch-sensitive surface have different contact patterns (e.g., different motions, timings, and/or intensities of detected contacts). Thus, a gesture is, optionally, detected by detecting a particular contact pattern. For example, detecting a finger tap gesture includes detecting a finger-down event followed by detecting a finger-up (liftoff) event at the same position (or substantially the same position) as the finger-down event (e.g., at the position of an icon). As another example, detecting a finger swipe gesture on the touch-sensitive surface includes detecting a finger-down event followed by detecting one or more finger-dragging events, and subsequently followed by detecting a finger-up (liftoff) event.

Graphics module 132 includes various known software components for rendering and displaying graphics on touch screen 112 or other display, including components for changing the visual impact (e.g., brightness, transparency, saturation, contrast, or other visual property) of graphics that are displayed. As used herein, the term “graphics” includes any object that can be displayed to a user, including, without limitation, text, web pages, icons (such as user-interface objects including soft keys), digital images, videos, animations, and the like.

In some embodiments, graphics module 132 stores data representing graphics to be used. Each graphic is, optionally, assigned a corresponding code. Graphics module 132 receives, from applications etc., one or more codes specifying graphics to be displayed along with, if necessary, coordinate data and other graphic property data, and then generates screen image data to output to display controller 156.

Haptic feedback module 133 includes various software components for generating instructions used by tactile output generator(s) 167 to produce tactile outputs at one or more locations on device 100 in response to user interactions with device 100.

Text input module 134, which is, optionally, a component of graphics module 132, provides soft keyboards for entering text in various applications (e.g., contacts 137, e-mail 140, IM 141, browser 147, and any other application that needs text input).

GPS module 135 determines the location of the device and provides this information for use in various applications (e.g., to telephone 138 for use in location-based dialing; to camera. 143 as picture/video metadata; and to applications that provide location-based services such as weather widgets, local yellow page widgets, and map/navigation widgets).

Applications 136 optionally include the following modules (or sets of instructions), or a subset or superset thereof:

-   -   Contacts module 137 called an address book or contact list);     -   Telephone module 138;     -   Video conference module 139;     -   E-mail client module 140;     -   Instant messaging (IM) module 141;     -   Workout support module 142;     -   Camera module 143 for still and/or video images;     -   Image management module 144;     -   Video player module;     -   Music player module;     -   Browser module 147;     -   Calendar module 148;     -   Widget modules 149, which optionally include one or more of:         weather widget 149-1, stocks widget 149-2, calculator widget         149-3, alarm clock widget 149-4, dictionary widget 149-5, and         other widgets obtained by the user, as well as user-created         widgets 149-6;     -   Widget creator module 150 for making user-created widgets 149-6;     -   Search module 151;     -   Video and music player module 152, which merges video player         module and music player module;     -   Notes module 153;     -   Map module 154; and/or     -   Online video module 155.

Examples of other applications 136 that are, optionally, stored in memory 102 include other word processing applications, other image editing applications, drawing applications, presentation applications, JAVA-enabled applications, encryption, digital rights management, voice recognition, and voice replication.

In conjunction with touch screen 112, display controller 156, contact/motion module 130, graphics module 132, and text input module 134, contacts module 137 are, optionally, used to manage an address book or contact list (e.g., stored in application internal state 192 of contacts module 137 in memory 102 or memory 370), including: adding name(s) to the address book; deleting name(s) from the address book; associating telephone number(s), e-mail address(es), physical address(es) or other information with a name; associating an image with a name; categorizing and sorting names; providing telephone numbers or e-mail addresses to initiate and/or facilitate communications by telephone 138, video conference module 139, e-mail 140, or IM 141; and so forth.

In conjunction with RF circuitry 108, audio circuitry 110, speaker 111, microphone 113, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, and text input module 134, telephone module 138 are optionally, used to enter a sequence of characters corresponding to a telephone number, access one or more telephone numbers in contacts module 137, modify a telephone number that has been entered, dial a respective telephone number, conduct a conversation, and disconnect or hang up when the conversation is completed. As noted above, the wireless communication optionally uses any of a plurality of communications standards, protocols, and technologies.

In conjunction with RF circuitry 108, audio circuitry 110, speaker 111, microphone 113, touch screen 112, display controller 156, optical sensor 164, optical sensor controller 158, contact/motion module 130, graphics module 132, text input module 134, contacts module 137, and telephone module 138, video conference module 139 includes executable instructions to initiate, conduct, and terminate a video conference between a user and one or more other participants in accordance with user instructions.

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, and text input module 134, e-mail client module 140 includes executable instructions to create, send, receive, and manage e-mail in response to user instructions. In conjunction with image management module 144, e-mail client module 140 makes it very easy to create and send e-mails with still or video images taken with camera module 143.

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, and text input module 134, the instant messaging module 141 includes executable instructions to enter a sequence of characters corresponding to an instant message, to modify previously entered characters, to transmit a respective instant message (for example, using a Short Message Service (SMS) or Multimedia Message Service (MMS) protocol for telephony-based instant messages or using XMPP, SIMPLE, or IMPS for Internet-based instant messages), to receive instant messages, and to view received instant messages. In some embodiments, transmitted and/or received instant messages optionally include graphics, photos, audio files, video files and/or other attachments as are supported in an MMS and/or an Enhanced Messaging Service (EMS). As used herein, “instant messaging” refers to both telephony-based messages (e.g., messages sent using SMS or MMS) and Internet-based messages (e.g., messages sent using XMPP, SIMPLE, or IMPS).

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, text input module 134, GPS module 135, map module 154, and music player module, workout support module 142 includes executable instructions to create workouts (e.g., with time, distance, and/or calorie burning goals); communicate with workout sensors (sports devices); receive workout sensor data; calibrate sensors used to monitor a workout; select and play music for a workout; and display, store, and transmit workout data.

In conjunction with touch screen 112, display controller 156, optical sensor(s) 164, optical sensor controller 158, contact/motion module 130, graphics module 132, and image management module 144, camera module 143 includes executable instructions to capture still images or video (including a video stream) and store them into memory 102, modify characteristics of a still image or video, or delete a still image or video from memory 102.

In conjunction with touch screen 112, display controller 156, contact/motion module 130, graphics module 132, text input module 134, and camera module 143, image management module 144 includes executable instructions to arrange, modify (e.g., edit), or otherwise manipulate, label, delete, present (e.g., in a digital slide show or album), and store still and/or video images.

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, and text input module 134, browser module 147 includes executable instructions to browse the Internet in accordance with user instructions, including searching, linking to, receiving, and displaying web pages or portions thereof, as well as attachments and other files linked to web pages.

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, text input module 134, e-mail client module 140, and browser module 147, calendar module 148 includes executable instructions to create, display, modify, and store calendars and data associated with calendars (e.g., calendar entries, to-do lists, etc.) in accordance with user instructions.

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, text input module 134, and browser module 147, widget modules 149 are mini-applications that are, optionally, downloaded and used by a user (e.g., weather widget 149-1, stocks widget 149-2, calculator widget 149-3, alarm clock widget 149-4, and dictionary widget 149-5) or created by the user (e.g., user-created widget 149-6). In some embodiments, a widget includes an HTML (Hypertext Markup Language) file, a CSS (Cascading Style Sheets) file, and a JavaScript file. In some embodiments, a widget includes an XML (Extensible Markup Language) file and a JavaScript file (e.g., Yahoo! Widgets).

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, text input module 134, and browser module 147, the widget creator module 150 are, optionally, used by a user to create widgets (e.g., turning a user-specified portion of a web page into a widget).

In conjunction with touch screen 112, display controller 156, contact/motion module 130, graphics module 132, and text input module 134, search module 151 includes executable instructions to search for text, music, sound, image, video, and/or other files in memory 102 that match one or more search criteria (e.g., one or more user-specified search terms) in accordance with user instructions.

In conjunction with touch screen 112, display controller 156, contact/motion module 130, graphics module 132, audio circuitry 110, speaker 111, RF circuitry 108, and browser module 147, video and music player module 152 includes executable instructions that allow the user to download and play back recorded music and other sound files stored in one or more file formats, such as MP3 or AAC files, and executable instructions to display, present, or otherwise play back videos (e.g., on touch screen 112 or on an external, connected display via external port 124). In some embodiments, device 100 optionally includes the functionality of an MP3 player, such as an iPod (trademark of Apple Inc.).

In conjunction with touch screen 112, display controller 156, contact/motion module 130, graphics module 132, and text input module 134, notes module 153 includes executable instructions to create and manage notes, to-do lists, and the like in accordance with user instructions.

In conjunction with RF circuitry 108, touch screen 112, display controller 156, contact/motion module 130, graphics module 132, text input module 134, GPS module 135, and browser module 147, map module 154 are, optionally, used to receive, display, modify, and store maps and data associated with maps (e.g., driving directions, data on stores and other points of interest at or near a particular location, and other location-based data) in accordance with user instructions.

In conjunction with touch screen 112, display controller 156, contact/motion module 130, graphics module 132, audio circuitry 110, speaker 111, RF circuitry 108, text input module 134, e-mail client module 140, and browser module 147, online video module 155 includes instructions that allow the user to access, browse, receive (e.g., by streaming and/or download), play back (e.g., on the touch screen or on an external, connected display via external port 124), send an e-mail with a link to a particular online video, and otherwise manage online videos in one or more file formats, such as H.264. In some embodiments, instant messaging module 141, rather than e-mail client module 140, is used to send a link to a particular online video. Additional description of the online video application can be found in U.S. Provisional Patent Application No. 60/936,562, “Portable Multifunction Device, Method, and Graphical User Interface for Playing Online Videos,” filed Jun. 20, 2007, and U.S. patent application Ser. No. 11/968,067, “Portable Multifunction Device, Method, and Graphical User Interface for Playing Online Videos,” filed Dec. 31, 2007, the contents of which are hereby incorporated by reference in their entirety.

Each of the above-identified modules and applications corresponds to a set of executable instructions for performing one or more functions described above and the methods described in this application (e.g., the computer-implemented methods and other information processing methods described herein). These modules (e.g., sets of instructions) need not be implemented as separate software programs, procedures, or modules, and thus various subsets of these modules are, optionally, combined or otherwise rearranged in various embodiments. For example, video player module is, optionally, combined with music player module into a single module (e.g., video and music player module 152, FIG. 1A). In some embodiments, memory 102 optionally stores a subset of the modules and data structures identified above. Furthermore, memory 102 optionally stores additional modules and data structures not described above.

In some embodiments, device 100 is a device where operation of a predefined set of functions on the device is performed exclusively through a touch screen and/or a touchpad. By using a touch screen and/or a touchpad as the primary input control device for operation of device 100, the number of physical input control devices (such as push buttons, dials, and the like) on device 100 is, optionally, reduced.

The predefined set of functions that are performed exclusively through a touch screen and/or a touchpad optionally include navigation between user interfaces. In some embodiments, the touchpad, when touched by the user, navigates device 100 to a main, home, or root menu from any user interface that is displayed on device 100. In such embodiments, a “menu button” is implemented using a touchpad. In some other embodiments, the menu button is a physical push button or other physical input control device instead of a touchpad.

FIG. 1B is a block diagram illustrating exemplary components for event handling in accordance with some embodiments. In some embodiments, memory 102 (FIG. 1A) or 370 (FIG. 3) includes event sorter 170 (e.g., in operating system 126) and a respective application 136-1 (e.g., any of the aforementioned applications 137-151, 155, 380-390).

Event sorter 170 receives event information and determines the application 136-1 and application view 191 of application 136-1 to which to deliver the event information. Event sorter 170 includes event monitor 171 and event dispatcher module 174. In some embodiments, application 136-1 includes application internal state 192, which indicates the current application view(s) displayed on touch-sensitive display 112 when the application is active or executing. In some embodiments, device/global internal state 157 is used by event sorter 170 to determine which application(s) is (are) currently active, and application internal state 192 is used by event sorter 170 to determine application views 191 to which to deliver event information.

In some embodiments, application internal state 192 includes additional information, such as one or more of: resume information to be used when application 136-1 resumes execution, user interface state information that indicates information being displayed or that is ready for display by application 136-1, a state queue for enabling the user to go back to a prior state or view of application 136-1, and a redo/undo queue of previous actions taken by the user.

Event monitor 171 receives event information from peripherals interface 118. Event information includes information about a sub-event (e.g., a user touch on touch-sensitive display 112, as part of a multi-touch gesture). Peripherals interface 118 transmits information it receives from I/O subsystem 106 or a sensor, such as proximity sensor 166, accelerometer(s) 168, and/or microphone 113 (through audio circuitry 110). Information that peripherals interface 118 receives from I/O subsystem 106 includes information from touch-sensitive display 112 or a touch-sensitive surface.

In some embodiments, event monitor 171 sends requests to the peripherals interface 118 at predetermined intervals. In response, peripherals interface 118 transmits event information. In other embodiments, peripherals interface 118 transmits event information only when there is a significant event (e.g., receiving an input above a predetermined noise threshold and/or for more than a predetermined duration).

In some embodiments, event sorter 170 also includes a hit view determination module 172 and/or an active event recognizer determination module 173.

Hit view determination module 172 provides software procedures for determining where a sub-event has taken place within one or more views when touch-sensitive display 112 displays more than one view. Views are made up of controls and other elements that a user can see on the display.

Another aspect of the user interface associated with an application is a set of views, sometimes herein called application views or user interface windows, in which information is displayed and touch-based gestures occur. The application views (of a respective application) in which a touch is detected optionally correspond to programmatic levels within a programmatic or view hierarchy of the application. For example, the lowest level view in which a touch is detected is, optionally, called the hit view, and the set of events that are recognized as proper inputs are, optionally, determined based, at least in part, on the hit view of the initial touch that begins a touch-based gesture.

Hit view determination module 172 receives information related to sub-events of a touch-based gesture. When an application has multiple views organized in a hierarchy, hit view determination module 172 identifies a hit view as the lowest view in the hierarchy which should handle the sub-event. In most circumstances, the hit view is the lowest level view in which an initiating sub-event occurs (e.g., the first sub-event in the sequence of sub-events that form an event or potential event). Once the hit view is identified by the hit view determination module 172, the hit view typically receives all sub-events related to the same touch or input source for which it was identified as the hit view.

Active event recognizer determination module 173 determines which view or views within a view hierarchy should receive a particular sequence of sub-events. In some embodiments, active event recognizer determination module 173 determines that only the hit view should receive a particular sequence of sub-events. In other embodiments, active event recognizer determination module 173 determines that all views that include the physical location of a sub-event are actively involved views, and therefore determines that all actively involved views should receive a particular sequence of sub-events. In other embodiments, even if touch sub-events were entirely confined to the area associated with one particular view, views higher in the hierarchy would still remain as actively involved views.

Event dispatcher module 174 dispatches the event information to an event recognizer (e.g., event recognizer 180). In embodiments including active event recognizer determination module 173, event dispatcher module 174 delivers the event information to an event recognizer determined by active event recognizer determination module 173. In some embodiments, event dispatcher module 174 stores in an event queue the event information, which is retrieved by a respective event receiver 182.

In some embodiments, operating system 126 includes event sorter 170. Alternatively, application 136-1 includes event sorter 170. In yet other embodiments, event sorter 170 is a stand-alone module, or a part of another module stored in memory 102, such as contact/motion module 130.

In some embodiments, application 136-1 includes a plurality of event handlers 190 and one or more application views 191, each of which includes instructions for handling touch events that occur within a respective view of the application's user interface. Each application view 191 of the application 136-1 includes one or more event recognizers 180. Typically, a respective application view 191 includes a plurality of event recognizers 180. In other embodiments, one or more of event recognizers 180 are part of a separate module, such as a user interface kit (not shown) or a higher level object from which application 136-1 inherits methods and other properties. In some embodiments, a respective event handler 190 includes one or more of: data updater 176, object updater 177, GUI updater 178, and/or event data 179 received from event sorter 170. Event handler 190 optionally utilizes or calls data updater 176, object updater 177, or GUI updater 178 to update the application internal state 192. Alternatively, one or more of the application views 191 include one or more respective event handlers 190. Also, in some embodiments, one or more of data updater 176, object updater 177, and GUI updater 178 are included in a respective application view 191.

A respective event recognizer 180 receives event information (e.g., event data 179) from event sorter 170 and identifies an event from the event information. Event recognizer 180 includes event receiver 182 and event comparator 184. In some embodiments, event recognizer 180 also includes at least a subset of: metadata 183, and event delivery instructions 188 (which optionally include sub-event delivery instructions).

Event receiver 182 receives event information from event sorter 170. The event information includes information about a sub-event, for example, a touch or a touch movement. Depending on the sub-event, the event information also includes additional information, such as location of the sub-event. When the sub-event concerns motion of a touch, the event information optionally also includes speed and direction of the sub-event. In some embodiments, events include rotation of the device from one orientation to another (e.g., from a portrait orientation to a landscape orientation, or vice versa), and the event information includes corresponding information about the current orientation (also called device attitude) of the device.

Event comparator 184 compares the event information to predefined event or sub-event definitions and, based on the comparison, determines an event or sub-event, or determines or updates the state of an event or sub-event. In some embodiments, event comparator 184 includes event definitions 186. Event definitions 186 contain definitions of events (e.g., predefined sequences of sub-events), for example, event 1 (187-1), event 2 (187-2), and others. In some embodiments, sub-events in an event (187) include, for example, touch begin, touch end, touch movement, touch cancellation, and multiple touching. In one example, the definition for event 1 (187-1) is a double tap on a displayed object. The double tap, for example, comprises a first touch (touch begin) on the displayed object for a predetermined phase, a first liftoff (touch end) for a predetermined phase, a second touch (touch begin) on the displayed object for a predetermined phase, and a second liftoff (touch end) for a predetermined phase. In another example, the definition for event 2 (187-2) is a dragging on a displayed object. The dragging, for example, comprises a touch (or contact) on the displayed object for a predetermined phase, a movement of the touch across touch-sensitive display 112, and liftoff of the touch (touch end). In some embodiments, the event also includes information for one or more associated event handlers 190.

In some embodiments, event definition 187 includes a definition of an event for a respective user-interface object. In some embodiments, event comparator 184 performs a hit test to determine which user-interface object is associated with a sub-event. For example, in an application view in which three user-interface objects are displayed on touch-sensitive display 112, when a touch is detected on touch-sensitive display 112, event comparator 184 performs a hit test to determine which of the three user-interface objects is associated with the touch (sub-event). If each displayed object is associated with a respective event handler 190, the event comparator uses the result of the hit test to determine which event handler 190 should be activated. For example, event comparator 184 selects an event handler associated with the sub-event and the object triggering the hit test.

In some embodiments, the definition for a respective event (187) also includes delayed actions that delay delivery of the event information until after it has been determined whether the sequence of sub-events does or does not correspond to the event recognizer's event type.

When a respective event recognizer 180 determines that the series of sub-events do not match any of the events in event definitions 186, the respective event recognizer 180 enters an event impossible, event failed, or event ended state, after which it disregards subsequent sub-events of the touch-based gesture. In this situation, other event recognizers, if any, that remain active for the hit view continue to track and process sub-events of an ongoing touch-based gesture.

In some embodiments, a respective event recognizer 180 includes metadata 183 with configurable properties, flags, and/or lists that indicate how the event delivery system should perform sub-event delivery to actively involved event recognizers. In some embodiments, metadata 183 includes configurable properties, flags, and/or lists that indicate how event recognizers interact, or are enabled to interact, with one another. In some embodiments, metadata 183 includes configurable properties, flags, and/or lists that indicate whether sub-events are delivered to varying levels in the view or programmatic hierarchy.

In some embodiments, a respective event recognizer 180 activates event handler 190 associated with an event when one or more particular sub-events of an event are recognized. In some embodiments, a respective event recognizer 180 delivers event information associated with the event to event handler 190. Activating an event handler 190 is distinct from sending (and deferred sending) sub-events to a respective hit view. In some embodiments, event recognizer 180 throws a flag associated with the recognized event, and event handler 190 associated with the flag catches the flag and performs a predefined process.

In some embodiments, event delivery instructions 188 include sub-event delivery instructions that deliver event information about a sub-event without activating an event handler. Instead, the sub-event delivery instructions deliver event information to event handlers associated with the series of sub-events or to actively involved views. Event handlers associated with the series of sub-events or with actively involved views receive the event information and perform a predetermined process.

In some embodiments, data updater 176 creates and updates data used in application 136-1. For example, data updater 176 updates the telephone number used in contacts module 137, or stores a video file used in video player module. In some embodiments, object updater 177 creates and updates objects used in application 136-1. For example, object updater 177 creates a new user-interface object or updates the position of a user-interface object. GUI updater 178 updates the GUI. For example, GUI updater 178 prepares display information and sends it to graphics module 132 for display on a touch-sensitive display.

In some embodiments, event handler(s) 190 includes or has access to data updater 176, object updater 177, and GUI updater 178. In some embodiments, data updater 176, object updater 177, and GUI updater 178 are included in a single module of a respective application 136-1 or application view 191. In other embodiments, they are included in two or more software modules.

It shall be understood that the foregoing discussion regarding event handling of user touches on touch-sensitive displays also applies to other forms of user inputs to operate multifunction devices 100 with input devices, not all of which are initiated on touch screens. For example, mouse movement and mouse button presses, optionally coordinated with single or multiple keyboard presses or holds; contact movements such as taps, drags, scrolls, etc. on touchpads; pen stylus inputs; movement of the device; oral instructions; detected eye movements; biometric inputs; and/or any combination thereof are optionally utilized as inputs corresponding to sub-events which define an event to be recognized.

FIG. 2 illustrates a portable multifunction device 100 having a touch screen 112 in accordance with some embodiments. The touch screen optionally displays one or more graphics within user interface (UI) 200. In this embodiment, as well as others described below, a user is enabled to select one or more of the graphics by making a gesture on the graphics, for example, with one or more fingers 202 (not drawn to scale in the figure) or one or more styluses 203 (not drawn to scale in the figure). In some embodiments, selection of one or more graphics occurs when the user breaks contact with the one or more graphics. In some embodiments, the gesture optionally includes one or more taps, one or more swipes (from left to right, right to left, upward and/or downward), and/or a rolling of a finger (from right to left, left to right, upward and/or downward) that has made contact with device 100. In some implementations or circumstances, inadvertent contact with a graphic does not select the graphic. For example, a swipe gesture that sweeps over an application icon optionally does not select the corresponding application when the gesture corresponding to selection is a tap.

Device 100 optionally also include one or more physical buttons, such as “home” or menu button 204. As described previously, menu button 204 is, optionally, used to navigate to any application 136 in a set of applications that are, optionally, executed on device 100. Alternatively, in some embodiments, the menu button is implemented as a soft key in a GUI displayed on touch screen 112.

In some embodiments, device 100 includes touch screen 112, menu button 204, push button 206 for powering the device on/off and locking the device, volume adjustment button(s) 208, subscriber identity module (SIM) card slot 210, headset jack 212, and docking/charging external port 124. Push button 206 is, optionally, used to turn the power on/off on the device by depressing the button and holding the button in the depressed state for a predefined time interval; to lock the device by depressing the button and releasing the button before the predefined time interval has elapsed; and/or to unlock the device or initiate an unlock process. In an alternative embodiment, device 100 also accepts verbal input for activation or deactivation of some functions through microphone 113. Device 100 also, optionally, includes one or more contact intensity sensors 165 for detecting intensity of contacts on touch screen 112 and/or one or more tactile output generators 167 for generating tactile outputs for a user of device 100.

FIG. 3 is a block diagram of an exemplary multifunction device with a display and a touch-sensitive surface in accordance with some embodiments. Device 300 need not be portable. In some embodiments, device 300 is a laptop computer, a desktop computer, a tablet computer, a multimedia player device, a navigation device, an educational device (such as a child's learning toy), a gaming system, or a control device (e.g., a home or industrial controller). Device 300 typically includes one or more processing units (CPUs) 310, one or more network or other communications interfaces 360, memory 370, and one or more communication buses 320 for interconnecting these components. Communication buses 320 optionally include circuitry (sometimes called a chipset) that interconnects and controls communications between system components. Device 300 includes input/output (I/O) interface 330 comprising display 340, which is typically a touch screen display. I/O interface 330 also optionally includes a keyboard and/or mouse (or other pointing device) 350 and touchpad 355, tactile output generator 357 for generating tactile outputs on device 300 (e.g., similar to tactile output generator(s) 167 described above with reference to FIG. 1A), sensors 359 (e.g., optical, acceleration, proximity, touch-sensitive, and/or contact intensity sensors similar to contact intensity sensor(s) 165 described above with reference to FIG. 1A). Memory 370 includes high-speed random access memory, such as DRAM, SRAM, DDR, RAM, or other random access solid state memory devices; and optionally includes non-volatile memory, such as one or more magnetic disk storage devices, optical disk storage devices, flash memory devices, or other non-volatile solid state storage devices. Memory 370 optionally includes one or more storage devices remotely located from CPU(s) 310. In some embodiments, memory 370 stores programs, modules, and data structures analogous to the programs, modules, and data structures stored in memory 102 of portable multifunction device 100 (FIG. 1A), or a subset thereof. Furthermore, memory 370 optionally stores additional programs, modules, and data structures not present in memory 102 of portable multifunction device 100. For example, memory 370 of device 300 optionally stores drawing module 380, presentation module 382, word processing module 384, website creation module 386, disk authoring module 388, and/or spreadsheet module 390, while memory 102 of portable multifunction device 100 (FIG. 1A) optionally does not store these modules.

Each of the above-identified elements in FIG. 3 is, optionally, stored in one or more of the previously mentioned memory devices. Each of the above-identified modules corresponds to a set of instructions for performing a function described above. The above-identified modules or programs (e.g., sets of instructions) need not be implemented as separate software programs, procedures, or modules, and thus various subsets of these modules are, optionally, combined or otherwise rearranged in various embodiments. In some embodiments, memory 370 optionally stores a subset of the modules and data structures identified above. Furthermore, memory 370 optionally stores additional modules and data structures not described above.

Attention is now directed towards embodiments of user interfaces that are, optionally, implemented on, for example, portable multifunction device 100.

FIG. 4A illustrates an exemplary user interface for a menu of applications on portable multifunction device 100 in accordance with some embodiments. Similar user interfaces are, optionally, implemented on device 300. In some embodiments, user interface 400 includes the following elements, or a subset or superset thereof:

-   -   Signal strength indicator(s) 402 for wireless communication(s),         such as cellular and Wi-Fi signals;     -   Time 404;     -   Bluetooth indicator 405;     -   Battery status indicator 406;     -   Tray 408 with icons for frequently used applications, such as:         -   Icon 416 for telephone module 138, labeled “Phone,” which             optionally includes an indicator 414 of the number of missed             calls or voicemail messages;         -   Icon 418 for e-mail client module 140, labeled “Mail,” which             optionally includes an indicator 410 of the number of unread             e-mails;         -   icon 420 for browser module 147, labeled “Browser;” and         -   Icon 422 for video and music player module 152, also             referred to as iPod (trademark of Apple Inc.) module 152,             labeled “iPod;” and     -   Icons for other applications, such as:         -   Icon 424 for IM module 141, labeled “Messages;”         -   icon 426 for calendar module 148, labeled “Calendar;”         -   Icon 428 for image management module 144, labeled “Photos;”         -   Icon 430 for camera module 143, labeled “Camera;”         -   Icon 432 for online video module 155, labeled “Online             Video;”         -   Icon 434 for stocks widget 149-2, labeled “Stocks;”         -   Icon 436 for map module 154, labeled “Maps;”         -   Icon 438 for weather widget 149-1, labeled “Weather;”         -   Icon 440 for alarm clock widget 149-4, labeled “Clock;”         -   Icon 442 for workout support module 142, labeled “Workout             Support;”         -   Icon 444 for notes module 153, labeled “Notes;” and         -   icon 446 for a settings application or module, labeled             “Settings,” which provides access to settings for device 100             and its various applications 136.

It should be noted that the icon labels illustrated in FIG. 4A are merely exemplary. For example, icon 422 for video and music player module 152 is labeled “Music” or “Music Player.” Other labels are, optionally, used for various application icons. In some embodiments, a label for a respective application icon includes a name of an application corresponding to the respective application icon. In some embodiments, a label for a particular application icon is distinct from a name of an application corresponding to the particular application icon.

FIG. 4B illustrates an exemplary user interface on a device (e.g., device 300, FIG. 3) with a touch-sensitive surface 451 (e.g., a tablet or touchpad 355, FIG. 3) that is separate from the display 450 (e.g., touch screen display 112). Device 300 also, optionally, includes one or more contact intensity sensors (e.g., one or more of sensors 359) for detecting intensity of contacts on touch-sensitive surface 451 and/or one or more tactile output generators 357 for generating tactile outputs for a user of device 300.

Although some of the examples that follow will be given with reference to inputs on touch screen display 112 (where the touch-sensitive surface and the display are combined), in some embodiments, the device detects inputs on a touch-sensitive surface that is separate from the display, as shown in FIG. 4B. In some embodiments, the touch-sensitive surface (e.g., 451 in FIG. 4B) has a primary axis (e.g., 452 in FIG. 4B) that corresponds to a primary axis (e.g., 453 in FIG. 4B) on the display (e.g., 450). In accordance with these embodiments, the device detects contacts (e.g., 460 and 462 in FIG. 4B) with the touch-sensitive surface 451 at locations that correspond to respective locations on the display (e.g., in FIG. 4B, 460 corresponds to 468 and 462 corresponds to 470). In this way, user inputs (e.g., contacts 460 and 462, and movements thereof) detected by the device on the touch-sensitive surface (e.g., 451 in FIG. 4B) are used by the device to manipulate the user interface on the display (e.g., 450 in FIG. 4B) of the multifunction device when the touch-sensitive surface is separate from the display. It should be understood that similar methods are, optionally, used for other user interfaces described herein.

Additionally, while the following examples are given primarily with reference to finger inputs (e.g., finger contacts, finger tap gestures, finger swipe gestures), it should be understood that, in some embodiments, one or more of the finger inputs are replaced with input from another input device (e.g., a mouse-based input or stylus input). For example, a swipe gesture is, optionally, replaced with a mouse click (e.g., instead of a contact) followed by movement of the cursor along the path of the swipe (e.g., instead of movement of the contact). As another example, a tap gesture is, optionally, replaced with a mouse click while the cursor is located over the location of the tap gesture (e.g., instead of detection of the contact followed by ceasing to detect the contact). Similarly, when multiple user inputs are simultaneously detected, it should be understood that multiple computer mice are, optionally, used simultaneously, or a mouse and finger contacts are, optionally, used simultaneously.

FIG. 5A illustrates exemplary personal electronic device 500. Device 500 includes body 502. In some embodiments, device 500 can include some or all of the features described with respect to devices 100 and 300 (e.g., FIGS. 1A-4B). In some embodiments, device 500 has touch-sensitive display screen 504, hereafter touch screen 504. Alternatively, or in addition to touch screen 504, device 500 has a display and a touch-sensitive surface. As with devices 100 and 300, in some embodiments, touch screen 504 (or the touch-sensitive surface) optionally includes one or more intensity sensors for detecting intensity of contacts (e.g., touches) being applied. The one or more intensity sensors of touch screen 504 (or the touch-sensitive surface) can provide output data that represents the intensity of touches. The user interface of device 500 can respond to touches based on their intensity, meaning that touches of different intensities can invoke different user interface operations on device 500.

Exemplary techniques for detecting and processing touch intensity are found, for example, in related applications: International Patent Application Serial No. PCT/US2013/040061, titled “Device, Method, and Graphical User Interface for Displaying User Interface Objects Corresponding to an Application,” filed May 8, 2013, published as WIPO Publication No. WO/2013/169849, and International Patent Application Serial No. PCT/US2013/069483, titled “Device, Method, and Graphical User Interface for Transitioning Between Touch Input to Display Output Relationships,” filed Nov. 11, 2013, published as WIPO Publication No. WO/2014/105276, each of which is hereby incorporated by reference in their entirety.

In some embodiments, device 500 has one or more input mechanisms 506 and 508. Input mechanisms 506 and 508, if included, can be physical. Examples of physical input mechanisms include push buttons and rotatable mechanisms. In some embodiments, device 500 has one or more attachment mechanisms. Such attachment mechanisms, if included, can permit attachment of device 500 with, for example, hats, eyewear, earrings, necklaces, shirts, jackets, bracelets, watch straps, chains, trousers, belts, shoes, purses, backpacks, and so forth. These attachment mechanisms permit device 500 to be worn by a user.

FIG. 5B depicts exemplary personal electronic device 500. In some embodiments, device 500 can include some or all of the components described with respect to FIGS. 1A, 1B, and 3. Device 500 has bus 512 that operatively couples I/O section 514 with one or more computer processors 516 and memory 518. I/O section 514 can be connected to display 504, which can have touch-sensitive component 522 and, optionally, intensity sensor 524 (e.g., contact intensity sensor). In addition, I/O section 514 can be connected with communication unit 530 for receiving application and operating system data, using Wi-Fi, Bluetooth, near field communication (NFC), cellular, and/or other wireless communication techniques. Device 500 can include input mechanisms 506 and/or 508. Input mechanism 506 is, optionally, a rotatable input device or a depressible and rotatable input device, for example. Input mechanism 508 is, optionally, a button, in some examples.

Input mechanism 508 is, optionally, a microphone, in some examples. Personal electronic device 500 optionally includes various sensors, such as GPS sensor 532, accelerometer 534, directional sensor 540 (e.g., compass), gyroscope 536, motion sensor 538, and/or a combination thereof, all of which can be operatively connected to I/O section 514.

Memory 518 of personal electronic device 500 can include one or more non-transitory computer-readable storage mediums, for storing computer-executable instructions, which, when executed by one or more computer processors 516, for example, can cause the computer processors to perform the techniques described below, including processes 1100-1200 (FIGS. 10-11). A computer-readable storage medium can be any medium that can tangibly contain or store computer-executable instructions for use by or in connection with the instruction execution system, apparatus, or device. In some examples, the storage medium is a transitory computer-readable storage medium. In some examples, the storage medium is a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium can include, but is not limited to, magnetic, optical, and/or semiconductor storages. Examples of such storage include magnetic disks, optical discs based on CD, DVD, or Blu-ray technologies, as well as persistent solid-state memory such as flash, solid-state drives, and the like. Personal electronic device 500 is not limited to the components and configuration of FIG. 5B, but can include other or additional components in multiple configurations.

As used here, the term “affordance” refers to a user-interactive graphical user interface object that is, optionally, displayed on the display screen of devices 100, 300, and/or 500 (FIGS. 1A, 3, and 5A-5B). For example, an image (e.g., icon), a button, and text (e.g., hyperlink) each optionally constitute an affordance.

As used herein, the term “focus selector” refers to an input element that indicates a current part of a user interface with which a user is interacting. In some implementations that include a cursor or other location marker, the cursor acts as a “focus selector” so that when an input (e.g., a press input) is detected on a touch-sensitive surface (e.g., touchpad 355 in FIG. 3 or touch-sensitive surface 451 in FIG. 4B) while the cursor is over a particular user interface element (e.g., a button, window, slider, or other user interface element), the particular user interface element is adjusted in accordance with the detected input. In some implementations that include a touch screen display (e.g., touch-sensitive display system 112 in FIG. 1A or touch screen 112 in FIG. 4A) that enables direct interaction with user interface elements on the touch screen display, a detected contact on the touch screen acts as a “focus selector” so that when an input (e.g., a press input by the contact) is detected on the touch screen display at a location of a particular user interface element (e.g., a button, window, slider, or other user interface element), the particular user interface element is adjusted in accordance with the detected input. In some implementations, focus is moved from one region of a user interface to another region of the user interface without corresponding movement of a cursor or movement of a contact on a touch screen display (e.g., by using a tab key or arrow keys to move focus from one button to another button); in these implementations, the focus selector moves in accordance with movement of focus between different regions of the user interface. Without regard to the specific form taken by the focus selector, the focus selector is generally the user interface element (or contact on a touch screen display) that is controlled by the user so as to communicate the user's intended interaction with the user interface (e.g., by indicating, to the device, the element of the user interface with which the user is intending to interact). For example, the location of a focus selector (e.g., a cursor, a contact, or a selection box) over a respective button while a press input is detected on the touch-sensitive surface (e.g., a touchpad or touch screen) will indicate that the user is intending to activate the respective button (as opposed to other user interface elements shown on a display of the device).

As used in the specification and claims, the term “characteristic intensity” of a contact refers to a characteristic of the contact based on one or more intensities of the contact. In some embodiments, the characteristic intensity is based on multiple intensity samples. The characteristic intensity is, optionally, based on a predefined number of intensity samples, or a set of intensity samples collected during a predetermined time period (e.g., 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10 seconds) relative to a predefined event (e.g., after detecting the contact, prior to detecting liftoff of the contact, before or after detecting a start of movement of the contact, prior to detecting an end of the contact, before or after detecting an increase in intensity of the contact, and/or before or after detecting a decrease in intensity of the contact). A characteristic intensity of a contact is, optionally, based on one or more of: a maximum value of the intensities of the contact, a mean value of the intensities of the contact, an average value of the intensities of the contact, a top 10 percentile value of the intensities of the contact, a value at the half maximum of the intensities of the contact, a value at the 90 percent maximum of the intensities of the contact, or the like. In some embodiments, the duration of the contact is used in determining the characteristic intensity (e.g., when the characteristic intensity is an average of the intensity of the contact over time). In some embodiments, the characteristic intensity is compared to a set of one or more intensity thresholds to determine whether an operation has been performed by a user. For example, the set of one or more intensity thresholds optionally includes a first intensity threshold and a second intensity threshold. In this example, a contact with a characteristic intensity that does not exceed the first threshold results in a first operation, a contact with a characteristic intensity that exceeds the first intensity threshold and does not exceed the second intensity threshold results in a second operation, and a contact with a characteristic intensity that exceeds the second threshold results in a third operation. In some embodiments, a comparison between the characteristic intensity and one or more thresholds is used to determine whether or not to perform one or more operations (e.g., whether to perform a respective operation or forgo performing the respective operation), rather than being used to determine whether to perform a first operation or a second operation.

In some embodiments, a portion of a gesture is identified for purposes of determining a characteristic intensity. For example, a touch-sensitive surface optionally receives a continuous swipe contact transitioning from a start location and reaching an end location, at which point the intensity of the contact increases. In this example, the characteristic intensity of the contact at the end location is, optionally, based on only a portion of the continuous swipe contact, and not the entire swipe contact (e.g., only the portion of the swipe contact at the end location). In some embodiments, a smoothing algorithm is, optionally, applied to the intensities of the swipe contact prior to determining the characteristic intensity of the contact. For example, the smoothing algorithm optionally includes one or more of: an unweighted sliding-average smoothing algorithm, a triangular smoothing algorithm, a median filter smoothing algorithm, and/or an exponential smoothing algorithm. In some circumstances, these smoothing algorithms eliminate narrow spikes or dips in the intensities of the swipe contact for purposes of determining a characteristic intensity.

The intensity of a contact on the touch-sensitive surface is, optionally, characterized relative to one or more intensity thresholds, such as a contact-detection intensity threshold, a light press intensity threshold, a deep press intensity threshold, and/or one or more other intensity thresholds. In some embodiments, the light press intensity threshold corresponds to an intensity at which the device will perform operations typically associated with clicking a button of a physical mouse or a trackpad. In some embodiments, the deep press intensity threshold corresponds to an intensity at which the device will perform operations that are different from operations typically associated with clicking a button of a physical mouse or a trackpad. In some embodiments, when a contact is detected with a characteristic intensity below the light press intensity threshold (e.g., and above a nominal contact-detection intensity threshold below which the contact is no longer detected), the device will move a focus selector in accordance with movement of the contact on the touch-sensitive surface without performing an operation associated with the light press intensity threshold or the deep press intensity threshold. Generally, unless otherwise stated, these intensity thresholds are consistent between different sets of user interface figures.

An increase of characteristic intensity of the contact from an intensity below the light press intensity threshold to an intensity between the light press intensity threshold and the deep press intensity threshold is sometimes referred to as a “light press” input. An increase of characteristic intensity of the contact from an intensity below the deep press intensity threshold to an intensity above the deep press intensity threshold is sometimes referred to as a “deep press” input. An increase of characteristic intensity of the contact from an intensity below the contact-detection intensity threshold to an intensity between the contact-detection intensity threshold and the light press intensity threshold is sometimes referred to as detecting the contact on the touch-surface. A decrease of characteristic intensity of the contact from an intensity above the contact-detection intensity threshold to an intensity below the contact-detection intensity threshold is sometimes referred to as detecting liftoff of the contact from the touch-surface. In some embodiments, the contact-detection intensity threshold is zero. In some embodiments, the contact-detection intensity threshold is greater than zero.

In some embodiments described herein, one or more operations are performed in response to detecting a gesture that includes a respective press input or in response to detecting the respective press input performed with a respective contact (or a plurality of contacts), where the respective press input is detected based at least in part on detecting an increase in intensity of the contact (or plurality of contacts) above a press-input intensity threshold. In some embodiments, the respective operation is performed in response to detecting the increase in intensity of the respective contact above the press-input intensity threshold (e.g., a “down stroke” of the respective press input). In some embodiments, the press input includes an increase in intensity of the respective contact above the press-input intensity threshold and a subsequent decrease in intensity of the contact below the press-input intensity threshold, and the respective operation is performed in response to detecting the subsequent decrease in intensity of the respective contact below the press-input threshold (e.g., an “up stroke” of the respective press input).

In some embodiments, the device employs intensity hysteresis to avoid accidental inputs sometimes termed “jitter,” where the device defines or selects a hysteresis intensity threshold with a predefined relationship to the press-input intensity threshold (e.g., the hysteresis intensity threshold is X intensity units lower than the press-input intensity threshold or the hysteresis intensity threshold is 75%, 90%, or some reasonable proportion of the press-input intensity threshold). Thus, in some embodiments, the press input includes an increase in intensity of the respective contact above the press-input intensity threshold and a subsequent decrease in intensity of the contact below the hysteresis intensity threshold that corresponds to the press-input intensity threshold, and the respective operation is performed in response to detecting the subsequent decrease in intensity of the respective contact below the hysteresis intensity threshold (e.g., an “up stroke” of the respective press input). Similarly, in some embodiments, the press input is detected only when the device detects an increase in intensity of the contact from an intensity at or below the hysteresis intensity threshold to an intensity at or above the press-input intensity threshold and, optionally, a subsequent decrease in intensity of the contact to an intensity at or below the hysteresis intensity, and the respective operation is performed in response to detecting the press input (e.g., the increase in intensity of the contact or the decrease in intensity of the contact, depending on the circumstances).

For ease of explanation, the descriptions of operations performed in response to a press input associated with a press-input intensity threshold or in response to a gesture including the press input are, optionally, triggered in response to detecting either: an increase in intensity of a contact above the press-input intensity threshold, an increase in intensity of a contact from an intensity below the hysteresis intensity threshold to an intensity above the press-input intensity threshold, a decrease in intensity of the contact below the press-input intensity threshold, and/or a decrease in intensity of the contact below the hysteresis intensity threshold corresponding to the press-input intensity threshold. Additionally, in examples where an operation is described as being performed in response to detecting a decrease in intensity of a contact below the press-input intensity threshold, the operation is, optionally, performed in response to detecting a decrease in intensity of the contact below a hysteresis intensity threshold corresponding to, and lower than, the press-input intensity threshold.

FIG. 6 illustrates a block diagram of text correction module 600 in accordance with some embodiments. In some examples, text correction module 600 is included in the memory (e.g., memory 102 or 370) of an electronic device (e.g., device 100, 300, or 500). As shown, text correction module 600 includes text boundary module 602, text correction model 604, and label application module 606. In some examples, text correction module 600 (and each of its sub-components) corresponds to a set of instructions for performing the various automatic text correction functions described below. For example, text correction module 600 includes instructions for performing the operations of process 1100, described below. The text correction functions provided by text correction module 600 are further described with reference to FIGS. 10A-10C, which illustrate an electronic device displaying user interfaces for performing automatic text correction in accordance with some embodiments.

In some examples, text correction module 600 is implemented in conjunction with the word processing features of an application (e.g., notes module 153, e-mail client module 140, or browser module 147) running on the electronic device. For example, text correction module 600 can include a set of inference application programming interfaces (APIs). The application can communicate with the components of text correction module 600 via the APIs to provide text input and receive indications of textual errors and suggested corrected text.

By way of example, FIG. 10A illustrates electronic device 1000 displaying user interface 1002 of the notes application (e.g., provided by notes module 153). Electronic device 1000 is similar to or the same as device 100 or 300, described above. During operation, text input is received from a user via keyboard 1004. For example, the text input module (e.g., text input module 134) of electronic device 1000 displays keyboard 1004 and receives the text input via keyboard 1004. In response to receiving the text input, the notes application causes display, on user interface 1002, of text string 1006 (“The whether is nice”), which corresponds to the received text input. In some examples, the text input module generates a token sequence representing text string 1006. Each token of the token sequence represents, for example, a respective word or phrase in text string 1006. Text correction module 600 receives the token sequence representing text string 1006 from the text input module and provides text correction functionality to identify and correct potential errors in text string 1006.

In the present example, text correction module 600 receives the token sequence representing text string 1006 from the text input module. In other examples, it should be recognized that the token sequence can be generated based on received speech input. For example, speech input is received from a user via a microphone (e.g., microphone 113) of the electronic device. An automatic speech recognition (ASR) module of the electronic device performs ASR processing on the received speech input and generates a text representation of the speech input. The text representation includes, for example, a token sequence representing the words or phrases in the text representation. Thus, in these examples, text correction module 600 receives the token sequence from the ASR module.

Upon receiving the token sequence representing text string 1006, text boundary module 602 processes the token sequence and determines whether an end of the token sequence corresponds to a text boundary, such as a sentence boundary, paragraph boundary, a document boundary, or the like. For example, text boundary module 602 analyzes the token sequence to determine whether text string 1006 “The whether is nice” forms a complete linguistic unit, such as a complete sentence or paragraph. Text boundary module 602 includes, for example, one or more statistical models (e.g., machine-learned models) and/or deterministic rules (e.g., grammar rules) for performing text boundary detection. In accordance with text boundary module 602 determining that the end of the token sequence corresponds to a text boundary, text correction model 604 processes the token sequence to identify any potential textual errors in text string 1006. Alternatively, in accordance with text boundary module 602 determining that the end of the token sequence does not correspond to a text boundary, text correction module 600 forgoes processing the token sequence using text correction model 604 to identify any potential textual errors.

By way of example, if text boundary module 602 analyzes the token sequence for the text string “The whether is,” text boundary module 602 would determine that the text string is more likely than not an incomplete sentence. As a result of this determination, text correction module 600 forgoes providing the token sequence to text correction model 604 and thus forgoes determining any potential textual errors in the text string. For example, in accordance with determining that the text string is more likely than not an incomplete sentence, text correction module 600 waits for additional tokens to be received (e.g., from the text input module or the ASR module).

If an additional token representing the word “nice” is subsequently received by text correction module 600, the token sequence is updated to represent text string 1006 “The whether is nice.” In this example, text boundary module 602 analyzes the updated token sequence and determines that text string 1006 is more likely than not a complete sentence. Thus, in this example, text correction module 600 provides the token sequence for “The whether is nice” to text correction model 604.

Text correction model 604 processes the token sequence and determines whether text string 1006 contains any textual errors. Text correction model 604 is, for example, a statistical model. In a specific example, text correction model 604 is a bidirectional LSTM RNN model. Text correction model 604 receives the token sequence and identifies, based on a context state of the token sequence, one or more textual errors at one or more tokens of the token sequence. In some examples, the context state is based on the entire token sequence. For example, text correction model 604 considers the entire text string 1006 (as opposed to only a portion of the text string) to identify any potential textual error in text string 1006. In some examples, any textual error in text string 1006 identified by text correction model 604 is based on the backward context state and the forward context state for the entire token sequence. For example, text correction model 604 identifies a textual error for the word “whether” in text string 1006 based on the words “is nice” after the word “whether” and based on the word “the” prior to the word “whether.”

In some examples, text correction model 604 identifies one or more textual errors by determining a sequence of labels for the token sequence and assigning each label of the sequence of labels to the respective tokens of the token sequence. Each label of the sequence of labels indicates whether or not the corresponding assigned token of the token sequence contains a textual error. For example, the sequence of labels includes one or more labels that are assigned to one or more tokens of the token sequences. The one or more labels specify one or more types of textual errors and thus indicate that there are one or more textual errors in the one or more tokens. The one or more labels correspond to one or more edit operations to perform on one or more tokens of the token sequence to correct the one or more textual errors. The remaining labels (other than the one or more labels) in the token sequence are assigned to the remaining tokens in the token sequence and indicate that there are no textual errors in the remaining tokens.

FIG. 7 illustrates text correction model 700 in accordance with some embodiments. In some examples, text correction model 604 is similar or the same as text correction model 700. The depiction of text correction model 700 in FIG. 7 is an unfolded representation across each of the time steps (1≤t≤T), where each token of the token sequence corresponds to a respective time step. For example, the first token of the token sequence corresponds to the first time step t=1 and the last token of the token sequence corresponds to the final time step t=T. As shown, text correction model 700 includes input layer 702, a bidirectional LSTM network comprising forward LSTM layer 704 and backward LSTM layer 706, and output layer 708. Each layer, for instance, comprises one or more units. These units, which in some examples are referred to as dimensions, neurons, or nodes (e.g., context nodes), operate as the computational elements of text correction model 700. The layers of text correction model 700 are interconnected using connections (as represented by the arrows in FIG. 7). Connections are unidirectional or bidirectional, and are further associated with respective weight values (or matrices). Weight values specifies a strength of the corresponding connection and, accordingly, the relative influence of the value provided via the connection. Each layer thus performs calculations by applying the weight values corresponding to the associated connection(s) and applying functions (linear or non-linear) defined according to the units of the layer.

The token sequence is received at input layer 702. In particular, input layer 702 processes a respective token of the token sequence at each time step t (for 1≤t≤T). In some examples, input layer 702 determines a feature vector (w_(t)) corresponding to each respective token of the token sequence. A vector representation of the token sequence is thus determined, where the vector representation includes a plurality of feature vectors (w_(t) for 1≤t≤T). In some examples, each feature vector is determined according to a lexicon. In particular, the lexicon includes a vocabulary of N words/phrases used to encode the tokens in the token sequence. In some examples, input layer 702 determines each feature vector by encoding the respective token of the token sequence using a one-hot encoding (1-of-N encoding) in accordance with the vocabulary of the lexicon. It should be recognized that, in some examples, other encoding techniques can be implemented. For instance, the feature vectors determined by input layer 702 can include feature embeddings for active features associated with the token sequence. The active features include, for example, lexical features (e.g., parts of speech, tense, plurality, word context, etc.) of the respective token. It should also be recognized that, in some examples, determining the feature vectors (w_(t)) corresponding to the token sequence can be performed by an encoding module separate from text correction model 700. In these examples, the encoding module provides the feature vectors (w_(t)) to forward LSTM layer 704 and backward LSTM layer 706 of text correction model 700 for further processing.

At each time step t (for 1≤t≤T), input layer 702 provides the feature vector (w_(t)) for the respective token in the token sequence to forward LSTM layer 704 and backward LSTM layer 706 of the LSTM network. Forward LSTM layer 704 and backward LSTM layer 706 each comprise one or more LSTM units (also referred to as LSTM blocks). In some examples, a LSTM unit is composed of a cell, an input gate, an output gate and a forget gate. The one or more LSTM units are, for example, gated recurrent units. Forward LSTM layer 704 receives the current feature vector (w_(t)) (e.g., at current time step t) from input layer 702 and the previous forward context state (s_(t−1)) (at previous time step t−1) from a recurrent connection of forward LSTM layer 704 and determines the current forward context state (s_(t)) of the current token. Backward LSTM layer 706 receives the current feature vector (w_(t)) (e.g., at current time step t) from input layer 702 and the subsequent backward context state (r_(t+1)) (at subsequent time step t+1) from a recurrent connection of backward LSTM layer 706 and determines the current backward context state (r_(t)) of the current feature vector (w_(t)).

The current forward context state (s_(t)) and backward context state (r_(t)) are received by output layer 708 from forward LSTM layer 704 and backward LSTM layer 706, respectively. Using the current forward context state (s_(t)) and backward context state (r_(t)), output layer 708 determine which of a plurality of predefined labels to assign to the current token corresponding to the current feature vector (w_(t)). In some examples, one of the plurality of predefined labels specifies that the corresponding token is not associated with any textual error (e.g., “default” label). The label thus indicates that no edit operations are to be performed on the corresponding token. The remaining labels of the plurality of predefined labels each specify a corresponding textual error of a plurality of predefined textual errors. For example, the remaining labels correspond to the plurality of predefined textual errors specified in table 900 of FIG. 9. In some examples, the remaining labels each correspond to one of a plurality of predefined edit operation to perform on the corresponding token.

In some examples, a first label of the plurality of predefined labels indicates a first type of textual error and corresponds to a first predefined edit operation. The first predefined edit operation is, for example, a replacement edit operation for replacing the corresponding token with a different token. In some examples, a second label of the plurality of predefined labels indicates a second type of textual error and corresponds to a second predefined edit operation. The second edit operation is, for example, an insert edit operation for inserting a new token before or after the corresponding token. It should be recognized that other labels of the plurality of predefined labels can correspond to various other edit operations such as deleting a token or reordering tokens.

In some examples, output layer 708 applies a softmax function and determines a probability distribution (y_(t)) over the plurality of predefined labels that can be assigned to the current token. The plurality of predefined labels include a limited number of predefined labels. For example, the plurality of predefined labels include less than 100, 200, or 500 unique labels. Based on the determined probability distribution (y_(t)), the label having the highest probability in the probability distribution is selected from the plurality of predefined labels and assigned to the current token. A respective label is assigned in a similar manner for each token in the token sequence over each time step t (for 1≤t≤T). In this way, a sequence of labels for the token sequence is determined where each token in the token sequence is assigned a respective label of the sequence of labels. It should be recognized that, in some examples, more than one label can be assigned to each token. For example, the three labels with the three highest probabilities in the probability distribution (y_(t)) are assigned to each token and thus three possible sequences of labels can be determined for the token sequence.

In some examples, at least two labels assigned to the token sequence by output layer 708 indicate that a segment of the token sequence contains a textual error. For example, output layer 708 assigns a first label to a first token of the token sequence and assigns a second label to a second token of the token sequence. The first and second labels define a segment of the token sequence. Specifically, the first label includes a start tag that defines the first token as the start of the segment and the second label includes an end tag that defines the second token as the end of the segment. The defined segment thus includes the first token, the second token, and any token(s) disposed between the first and second tokens. In this example, the first and second labels indicate that a corresponding predefined edit operation is to be applied to the two or more tokens in the defined segment.

In some examples, a third label assigned to the token sequence by output layer 708 indicates that a third token contains a textual error. For example, output layer 708 assigns the third label to the third token. The third token indicates that a corresponding predefined edit operation is to be applied to only the third token (e.g., no more than the third token). For example, the third label includes both a start tag and an end tag, which indicate that the corresponding predefined edit operation is to be applied only to the third token. In a specific example, the corresponding predefined edit operation is a replacement edit operation for replacing the third token with a different token.

In some examples, because text correction model 700 is constrained to a limited number of possible labels (e.g., less than 100, 200, or 500 unique labels) representing a limited number of edit operations, text correction model 700 is a simplified and compact statistical model. In this way, less training data is required for text correction model 700 to achieve an accuracy that is similar to or exceeds that of conventional text correction solutions. Text correction model 700 can thus be generated faster and also require less computer resources to store and operate. This, in turn, can improve the battery life of the device implementing text correction model 700.

Although, in the present example, text correction model 700 is a bidirectional LSTM RNN model, it should be recognized that other statistical models can be used without departing from the scope of the present invention. For instance, in some examples, the text correction model is a bidirectional RNN model. In addition, it should be appreciated that, in other examples, an arbitrarily complex, deep network can be implemented. For example, the text correction model can include two or more bidirectional RNN/LSTM networks stacked on top of one another. Moreover, it should be appreciated that the text correction model can include one or more multilayer perceptron hidden layers between the LSTM network(s) and the output layer.

With reference back to FIG. 6 and the example of FIG. 10A, text correction model 604 processes the token sequence representing text string 1006 and determines a sequence of labels to assign to the token sequence. In the present example, the determined sequence of labels includes a first label assigned to a first token representing the word “the,” a second label assigned to a second token representing the word “whether,” a third label assigned to a third token representing the word “is,” and a fourth token assigned to a fourth token representing the word “nice.” Each token of the token sequence is selected from a plurality of predefined labels. In the presented example, the first, third, and fourth tokens are each “default” labels indicating that the tokens representing the words “the,” “is,” and “nice” in text string 1006 do not contain any textual errors. The second label includes a <homophone> start tag and a <\homophone> end tag, which indicate that the second token representing the word “whether” contains a homophone confusion textual error. In the present example, the second label corresponds to a replacement edit operation for replacing the token for “whether” with the token for “weather.” Based on the second label in the sequence of labels, text correction module 600 determines that the word “whether” in text string 1006 contains a textual error. In accordance with this determination, text correction module 600 provides (e.g., via the APIs) an indication to the notes module (e.g., notes module 153) specifying that the word “whether” in text string 1006 contains an error. In response to receiving the indication from text correction module 600, the notes module, in conjunction with the graphics module (e.g., graphics module 132) of the electronic device, causes electronic device 1000 to display error indication 1008, as shown in FIG. 10B. Error indication 1008 defines the portion of text string 1006 (e.g., the word “whether”) that contains the textual error. In the present example, error indication 1008 defines the portion of text string 1006 corresponding to the second token.

Although in the present example, error indication 1008 is an underline of the word “whether,” it should be recognized that other techniques for providing an error indication can be implemented. For example, the error indication can be in the form of highlighting, bolding, or italicizing the portion of the text string that contains the textual error. In some examples, the error indication can include an affordance that overlaps or is proximate to the portion of the text string that contains the error.

Label application module 606 receives the sequence of labels from text correction model 604 and generates corrected text for the portion of text string 1006 containing the textual error. In particular, label application module 606 determines the edit operation corresponding to the textual error. In some example, the edit operation is determined using a look-up table or database. The look-up table maps a plurality of predefined labels to a plurality of predefined edit operations. For example, a look-up table similar to table 900 can be used to determine the edit operation corresponding to the textual error for “whether.” In particular, using table 900, label application module 606 maps the second label (e.g., <homophone> whether <\homophone>) to the first column of table 900 (e.g., homophone confusion textual errors), which corresponds to a replacement edit operation. For example, based on the word pair “whether/weather” (or a corresponding rule) in the first column of table 900, label application module 606 determines that the edit operation corresponding to the second label is to replace the second token for “whether” with the corrected token “weather.” Label application module 606 applies the edit operation to the second token representing the word “whether” to generate the corrected text “weather.”

Although in the present example of FIGS. 10A-10D, text correction model 604 only determines one sequence of labels to assign to the token sequence representing the text string, it should be recognized that, in some examples, two or more sequence of labels are assigned to the token sequence. In these examples, label application module 606 can apply the two or more sequence of labels to generate two or more candidate corrected text for the portion of the text string containing the textual error.

In the present example, text correction module 600 provides the corrected text “weather” to the text input module and/or notes module (e.g., via the APIs) of electronic device 1000. In response to receiving a user input (e.g., touch input by finger 1010) selecting error indication 1008, the text input module, in conjunction with the graphics module, causes electronic device 1000 to display the corrected text 1012 “weather”, as shown in FIG. 10C. In this example, corrected text 1012 is displayed in keyboard 1004. It should be appreciated that, in some examples, the corrected text can be presented in a different manner, such as in user interface 1002 (e.g., adjacent to error indication 1008). Moreover, it should be appreciated that in examples where two or more candidate corrected texts are generated by label application module 606, the two or more candidate corrected texts can be displayed for user selection.

As shown in FIG. 10D, a user selects the displayed corrected text 1012 (e.g., with a touch input by finger 1010). In response to detecting (e.g., by contact/motion module 130 via touchscreen 112) a user selection of the displayed corrected text 1012, the text input module, in conjunction with the graphics module and the notes module, causes electronic device 1000 to replace the word “whether” in user interface 1002 with the corrected text 1012. “weather.” As a result, corrected text string 1014 “The weather is nice” is displayed on user interface 1002. While the example depicted in FIGS. 10A-10D describes the application of text correction module 600 to correct a homophone confusion error in a sentence, it should be appreciate that text correction module 600 can be adapted to detect other classes of semantic errors (e.g., wrong co-reference, discourse level inconsistencies, etc.) and can be applied to longer linguistic units such as paragraphs or entire documents.

Although in the example of FIGS. 10A-10D, the word “whether” in user interface 1002 is replaced with the corrected text 1012 “weather” in response to receiving user input (e.g., touch input by finger 1010), it should be recognized that, in other examples, the corrected text 1012 “weather” can be automatically replaced (e.g., by the text input module and/or notes module of electronic device 1000). For instance, in some examples, the corrected text 1012 “weather” is associated with a confidence measure. For example, the confidence measure is the probability (e.g., from probability distribution (y_(t))) of the second label being assigned to the second token representing the word “whether.” In accordance with the confidence measure satisfying a predefined condition, the word “whether” in user interface 1002 is automatically replaced (e.g., without any further user input, such as touch input(s) by finger 1010) with the corrected text 1012 “weather.” In some examples, the predefined condition includes the condition that the confidence measure meets or exceeds a predefined threshold. In some examples, the word “whether” in user interface 1002 is automatically replaced with the corrected text 1012 “weather” in accordance with the confidence measure satisfying a predefined condition and in accordance with the user proceeding to input text for a new sentence (e.g., entering additional text after the determination that text string 1006 is more likely than not a complete sentence).

Text correction models 604 and 700, described above, are generated using one or more sets of training data. In conventional training techniques, it can be difficult to obtain training data with labeled examples. For example, obtaining sentences with known textual errors (e.g., confused homophones, missing apostrophe, subject-verb disagreement, incorrect use of diacritic, etc.) can be difficult without infringing on the privacy of the user. In accordance with various techniques described herein, training data for training text correction models (e,g., text correction models 604 and 700) can be automatically generated.

FIG. 8 illustrates a block diagram of model generation module 800 in accordance with some embodiments. In some examples, model generation module 800 is included in the memory of one or more electronic devices. For example, model generation module 800 is included in the memory of one or more servers used to generate a text correction model, such as text correction model 604 or 700. As shown, model generation module 800 includes error-inducing mechanism 802, training data generation module 804, and model training module 806. In some examples, model generation module 800 (and each of its sub-components) corresponds to a set of instructions for performing the various training data generation and model training functions described below. For example, model generation module 800 includes instructions for performing the operations of process 1200, described below.

Error-inducing mechanism 802 is configured to receive a substantially error-free corpus of text and induce textual errors in the corpus of text. The corpus of text is obtained from journal articles, open source books, technical reports, or the like. In some examples, the textual errors induced by error-inducing mechanism 802 are based on one or more sets of word pairs predefined by a linguist. Each word pair in the one or more sets of word pairs includes a positive word example and a negative word example. For example, FIG. 9 illustrates table 900 having several sets of word pairs that represent various types of textual errors in accordance with some embodiments. The word pairs depicted in table 900 are generated, for example, by a linguist. As shown, table 900 includes four columns representing textual errors associated with confused homophones, missing apostrophe, missing article/determiner, and subject-verb disagreement. The word pairs in each column of table 900 correspond to specific examples of the respective types of textual errors. For example, “whether/weather” is a word pair representing a positive/negative example pair for confused homophones.

In some examples, error-inducing mechanism 802 includes rules (e.g., deterministic rules) and/or models (e.g., statistical models) that are configured to recognize, in a sample of text (e.g., sentence, paragraph, or corpus of text), a positive example from the one or more sets of word pairs and replace the positive example with the corresponding negative example. The rules and/or models correspond, for example, to the word pairs specified in the one or more sets of word pairs. In some examples, the rules and/or models account for the surrounding context, syntax, and/or grammar when recognizing the positive examples and inducing the textual errors corresponding to the negative examples. Thus, in operation, upon receiving a corpus of text that is substantially error-free, error-inducing mechanism 802 applies the rules and/or models to induce textual errors (e.g., corresponding to the textual errors of table 900) in the corpus of text and thus generates an error-induced corpus of text. For example, error-inducing mechanism 802 applies a rule or model to recognize the positive example “weather” in the sentence “The weather is nice” and to replace the word with the negative example “whether” to generate the error-induced sentence “The whether is nice.” In some examples, the generated error-induced corpus of text includes a plurality of textual errors corresponding to at least a portion of the one or more sets of word pairs defined by the linguist.

Training data generation module 804 is configured to automatically generate training data based on the corpus of text, the error-induced corpus of text (e.g., generated by error-inducing mechanism 802), and the rules and/or models of error-inducing mechanism 802. For example, training data generation module 804 generates a plurality of word sequence pairs. Each word sequence pair of the plurality of word sequence pairs corresponds to a linguistic unit (e.g., a sentence, paragraph, etc.) in the corpus of text. Additionally, each word sequence pair includes a positive word sequence from the corpus of text and a negative word sequence from the error-induced corpus of text. By way of example, a word sequence pair can include the positive sentence “The weather is nice” from the corpus of text and the corresponding negative sentence “The whether is nice” from the error-induced corpus of text.

In some examples, training data generation module 804 generates a set of labeled training data from the corpus of text, the error-induced corpus of text, and the rules and/or models of error-inducing mechanism 802. For example, training data generation module 804 assigns labels to words or phrases in the error-induced corpus of text to automatically generate labeled training data. In some examples, the labels assigned by training data generation module 804 are selected from a set of predefined labels. The set of predefined labels includes a “default” label, which indicates that the corresponding word/phrase is not associated with a textual error of the one or more sets of word pairs. The remaining labels in the set of predefined labels each indicate a corresponding textual error of the one or more sets of word pairs. In some examples, training data generation module 804 assigns labels based on the rules and/or models of error-inducing mechanism 802. For example, based on the rules and/or models of error-inducing mechanism 802, training data generation module 804 recognizes that the word “whether” in the negative sentence “The whether is nice” corresponds to a homophone confusion textual error of the word pair “whether/weather.” As a result, training data generation module 804 assigns, to the word “whether,” a label that indicates the homophone confusion textual error of “whether/weather.” Training data generation module 804 also assigns the “default” label to each of the remaining words in the negative sentence (e.g., “the,” “is,” and “nice”). In some examples, the “default” label indicates that no edit operations are to be applied to the respective words. In some examples, the label assigned to the word “whether” indicates that the edit operation of replacing the word with the positive example “weather” is to be applied to the word “whether.”

Using the training data generated by training data generation module 804, model training module 806 is configured to train a model for correcting textual errors. For example, model training module 806 uses the training data from training data generation module 804 to generate text correction model 604 or 700. In some examples, model training module 806 applies machine-learning algorithms to train statistical text correction models using the generated training data. In some examples, the text correction models trained by training module 806 are bidirectional LSTM recurrent neural network models.

It should be appreciated that the process implemented by model generation module 800 to generate training data is flexible and scalable. In particular, error-inducing mechanism 802 can induce any type of textual error in a substantially error-free corpus of text to generate an error-induced corpus of text for training data generation module 804. The resultant training data generated by training data generation module 804 using the error-induced corpus of text can then be used by model training module 806 to generate a text correction model for correcting any type of textual error in the context of a linguistic unit (e.g., sentence, paragraph, etc.). Examples of other types of textual errors that can be applied to model generation module 800 include, for example, diacritic confusions (e.g., tu/tú), mistyped words due to common transposition errors of keys on the keyboard (e.g., rick/rock, car/cat), wrong-word-in-context errors, or the like. The textual errors can involve individual words or multiple words.

The automatic process of generating training data using model generation module 800 can be advantageous because no externally labelled data is required to generate the text correction model. In addition, the process reduces the need for manual annotation, which reduces cost and avoids external dependencies. As mentioned above, the process can also be easily scalable where the sets of word pairs can be expanded and corresponding training data can be quickly generated to update the model. Moreover, error-inducing mechanism 802 can be adapted to induce textual errors according to any arbitrary bias rate. For example, one textual error can be induced for every two error-free sentences in the corpus of text. This can be desirable to implement curriculum-style learning for any class of problems.

FIG. 11 is a flow diagram illustrating process 1100 for text correction using an electronic device in accordance with some embodiments. Process 1100 is performed, for example, at a device (e.g., 100, 300, 500) with a display. Some operations in process 1100 are, optionally, combined, the orders of some operations are, optionally, changed, and some operations are, optionally, omitted.

As described in greater detail below, process 1100 includes receiving text input. In response to receiving the text input, a text string corresponding to the text input is displayed. The text string is represented by a token sequence. Process 1100 determines whether an end of the token sequence corresponds to a text boundary. In accordance with a determination that the end of the token sequence corresponds to a text boundary, process 1100 determines, based on a context state of the token sequence, one or more textual errors at one or more tokens of the token sequence. An error indication for a portion of the text string corresponding to the one or more tokens is displayed.

Determining, based on a context state of the token sequence, the one or more textual errors in accordance with a determination that the end of the token sequence corresponds to a text boundary can improve the accuracy and efficiency of text correction by the electronic device. In particular, the determination that the end of the token sequence corresponds to a text boundary can increase the likelihood that the token sequence corresponds to a complete linguistic unit (e.g., complete sentence, paragraph, or document). This can enable each token in the token sequence to be evaluated for textual errors based on more comprehensive and useful contextual information. For example, the context state of the entire linguistic unit (e.g., forward and backward context) can be considered in determining textual errors. This improves the accuracy and efficiency of identifying and correcting textual errors, which improves the function of the electronic device.

At block 1102, text input is received (e.g., via touchscreen 112 and using text input module 134). In some examples, the text input represents a text string containing a plurality of words.

At block 1104, in response to receiving the text input, a text string (e.g., text string 1006 of FIG. 10A) corresponding to the text input is displayed (e.g., on touchscreen 112 or display 340 and by graphics module 132). The text string is represented by a token sequence.

At block 1106, a determination is made (e.g., by text boundary module 602) as to whether an end of the token sequence corresponds to a text boundary. In accordance with a determination that the end of the token sequence does not correspond to a text boundary, process 1100 forgoes performing text correction analysis on the token sequence. Conversely, in accordance with a determination that the end of the token sequence corresponds to a text boundary, the operations of one or more of blocks 1108-1124 are performed.

At block 1108, based on a context state of the token sequence, one or more textual errors are identified (e,g., using text correction model 604) at one or more tokens of the token sequence. In some examples, a textual error of the one or more textual errors is identified at a token of the one or more tokens. In particular, the textual error is identified based on a backward context state of the token and a forward context state of the token. In some examples, the context state used to identify the one or more textual errors is based on the entire token sequence.

At block 1110, a vector representation for the token sequence is determined (e.g., by input layer 702 of text correction model 700).

At block 1112, based on the vector representation, a sequence of labels to assign to the token sequence is determined (e.g., at the output layer of text correction model 700). In some examples, one or more labels of the determined sequence of labels indicate the one or more textual errors. In some examples, the one or more labels correspond to one or more edit operations to perform on the one or more tokens.

In some examples, a first label of the one or more labels is assigned to a first token of the one or more tokens. The first label corresponds to a first edit operation of the one or more edit operations. The first edit operation is, for example, a replacement edit operation for replacing the first token with a different token.

In some examples, a second label of the one or more labels is assigned to a second token of the one or more tokens. The second label corresponds to a second edit operation of the one or more edit operations. The second edit operation is, for example, an insert edit operation for inserting a new token before or after a second token of the one or more tokens.

In some examples, a third label of the one or more labels is assigned to a third token of the one or more tokens. The third label corresponds to a third edit operation of the one or more edit operations. In particular, the third label specifies that the third edit operation is to be applied to only the third token (e.g., no more than one token of the one or more tokens). For example, the third label includes both “start” and “end” tags, which indicate that the corresponding third edit operation is to be applied to only the third token.

In some examples, the one or more labels include at least two labels that define a segment of the token sequence. For example, the at least two labels include a fourth label and a fifth label that are respectively assigned to a fourth token and a fifth token of the token sequence. The fourth label includes a “start” tag, which defines the fourth token as the start of the segment. The fifth label includes an “end” tag, which defines the fifth token as the end of the segment. Thus, the segment includes two or more tokens in the token sequence (e.g., the fourth token, the fifth token, and any token(s) between the fourth and fifth tokens). In these examples, the at least two labels correspond to a fourth edit operation that is to be applied to the two or more tokens in the defined segment.

In some examples, determining the sequence of labels includes selecting each label of the sequence of labels from a plurality of predefined labels (e.g., by output layer 708 of text correction model 700). In some examples, each predefined label of the plurality of predefined labels corresponds to a respective predefined edit operation of a plurality of predefined edit operations. The plurality of predefined labels contain a limited number of labels (e.g., less than 100, 200, or 500). By constraining the statistical model (e.g., text correction model 604 or 700) to a limited number of labels corresponding to a limited number of edit operations, the degree of any error committed by the model can be limited. In addition, constraining the statistical model results in a simplified model, which can reduce the amount of training data required to build an accurate model. Furthermore, because less training data is required, the model can be generated faster and can require less computer resources to store and operate. This, in turn, can improve the battery life of the device.

In some examples, determining the sequence of labels includes determining, for a label of the sequence of labels, a probability (e.g., from the probability distribution determined at output layer 708 of text correction model 700) for assigning the label to a token of the token sequence. The label is selected from the plurality of predefined labels based on the determined probability. For example, the label is selected in accordance with the determined probability being the highest probability in the probability distribution for the plurality of predefined labels.

In some examples, determining the sequence of labels includes assigning each token in the token sequence with a respective label of the sequence of labels. Thus, every token of the token sequence is assigned a respective label.

In some examples, the sequence of labels includes a label indicating that no edit operations are to be performed on an associated token of the token sequence. For example, the label is a “default” label indicating that the associated token does not contain a textual error.

In some examples, determining the sequence of labels includes determining a context-dependent feature vector of a current token (e.g., w_(t)) in the token sequence based on a current backward context state (e.g., r_(t)) of the current token and a current forward context state (e.g., s_(t)) of the current token (e.g., using backward and forward LSTM layers 706, 704 of text correction model 700). For example, the context-dependent feature vector is determined based on a combination of the current backward context state (e.g., r_(t)) and the current forward context state (e.g., s_(t)). Based on the context-dependent feature vector of the current token, a plurality of probabilities (e.g., probability distribution y_(t)) associated with a plurality of predefined labels are determined (e.g., using output layer 708 of text correction model 700). Based on the plurality of probabilities, a label is selected from the plurality of predefined labels to assign to the current token. The selected label is, for example, associated with the highest probability of the plurality of probabilities.

At block 1114, an error indication (e.g., error indication 1008 of FIG. 10B) is displayed (e.g., on touchscreen 112 and using graphics module 132) for a portion of the text string corresponding to the one or more tokens.

At block 1116, the one or more edit operations corresponding to the one or more textual errors are determined (e.g., using label application module 606). In some examples, the one or more edit operations are determined from the plurality of predefined edits operations.

At block 1118, the one or more edit operations of block 1116 are applied (e.g., using label application module 606) to the one or more tokens to generate corrected text for the portion of the text string. In some examples, the one or more edit operations are applied according to one or more predefined rules corresponding to the one or more labels.

At block 1120, user input (e.g., touch input by finger 1010 in FIG. 10C) selecting the displayed error indication of block 1114 is received (e.g., at context/motion module 130 via touchscreen 112).

At block 1122, in response to receiving the user input of block 1120, the corrected text (e.g., corrected text 1012 of FIG. 10C) is displayed (e.g., on touchscreen 112 using graphics module 132) for user selection.

At block 1124, in response to detecting a user selection (e.g., touch input by finger 1010 as shown in FIG. 10D) of the displayed corrected text, the displayed portion of the text string is replaced with the corrected text (e.g., corrected text string 1014 in FIG. 10D).

Although in the current example, the displayed portion of the text is replaced with the corrected text in response to receiving user input, it should be recognized that, in other examples, the corrected text can be automatically replaced. For instance, in some examples, the corrected text generated at block 1118 is associated with a confidence measure. The confidence measure is, for example, based on the one or more probabilities associated with the one or more labels. In accordance with the confidence measure satisfying a predefined condition, the displayed portion of the text string is automatically (e.g., without further input from the user) replaced with the corrected text. In some examples, the predefined condition includes the condition that the confidence measure meets or exceeds a predefined threshold.

The operations described above with reference to FIG. 11 are optionally implemented by components depicted in FIGS. 1A, 3, 6, and 7. For example, the operations of process 1100 are implemented by contact/motion module 130, graphics module 132, applications 136, and touchscreen 112. The operations of process 1200 are further implemented by text correction module 600, including text boundary module 602, text correction model 604 or 700, and label application module 606. It would be clear to a person having ordinary skill in the art how other exemplary processes are implemented based on the components depicted in FIGS. 1A, 3, 6, and 7.

FIG. 12 is a flow diagram illustrating process 1200 for generating a text correction model in accordance with some embodiments. Process 1200 is performed, for example, at one or more devices (e.g., servers). Some operations in method 1200 are, optionally, combined, the orders of some operations are, optionally, changed, and some operations are, optionally, omitted.

As described is greater detail below, process 1200 includes obtaining a plurality of word pairs and a corpus of text. Each word pair of the plurality of word pairs includes a positive word example and a negative word example. Based on the obtained corpus of text and the plurality of word pairs, an error-induced corpus of text is generated. The error-induced corpus of text includes a plurality of textual errors corresponding to at least a portion of the plurality of word pairs. Process 1200 generates training data from the corpus of text and the error-induced corpus of text. A text correction model is trained using the training data. The trained text correction model is applied to a text string to produce corrected text.

Automatically generating an error-induced corpus of text based on the obtained corpus of text and the plurality of word pairs can enable efficient and scalable generation of text correction models. In particular, it can enable training data to be generated without externally labelled data or manual annotation. In addition, the technique can be easily scalable where the plurality of word pairs can be expanded and corresponding training data can be quickly generated to update the model. In this way, text correction models can be more quickly and efficiently generated and updated.

At block 1202, a plurality of word pairs are obtained (e.g., word pairs depicted in table 900 of FIG. 9). Each word pair of the plurality of word pairs includes a positive word example and a negative word example. The plurality of word pairs are generated, for example, by a linguist.

At block 1204, a corpus of text is obtained. The corpus of text is substantially free of textual errors. In some examples, the corpus of text is obtained from journal articles, open source books, technical reports, or the like.

At block 1206, based on the corpus of text and the plurality of word pairs, an error-induced corpus of text is generated (e.g., using error-inducing mechanism 802). The error-induced corpus of text includes a plurality of textual errors corresponding to at least a portion of the plurality of word pairs. In some examples, a plurality of rules corresponding to the plurality of word pairs are obtained and the error-induced corpus of text is generated by applying the plurality of rules to the corpus of text. In some examples, the plurality of rules are generated by a linguist based on the plurality of word pairs.

At block 1208, training data from the corpus of text and the error-induced corpus of text are generated (e.g., using training data generation module 804). In some examples, the training data includes a plurality of word sequence pairs. Each word sequence pair of the plurality of word sequence pairs includes a positive word sequence from the corpus of text and a negative word sequence from the error-induced corpus of text.

At block 1210, a text correction model (e.g., text correction model 604 or 700) is trained using the training data (e.g., using model training module 806). For example, the text correction model is trained using machine-learning algorithms. In some examples, the trained text correction model is a statistical model, such as a bidirectional long short-term memory recurrent neural network model.

At block 1212, the trained text correction model is applied to a text string (e.g., text string 1006 of FIG. 10A) to produce corrected text (e.g., corrected text 1012 of FIG. 10C and corrected text string 1014 of FIG. 10D). In some examples, the trained text correction model is applied to a text string using operations described above in process 1100. For example, a sequence of labels to assign to a token sequence representing the text string is determined (block 1112). In some examples, a first label of the sequence of labels indicates a textual error in a first token of the token sequence. The first label is determined based on a backward context state (e.g., r_(t)) of the first token and a forward context state (e.g., s_(t)) of the first token. The corrected text is produced by applying, to the first token, an edit operation corresponding to the first label.

The operations described above with reference to FIG. 12 are optionally implemented by components depicted in FIGS. 1A, 3, and 6-8. For example, the operations of process 1200 are implemented by model generation module 800, including error-inducing mechanism 802, training data generation module 804, and model training module 806. Some operations of process 1200 (e.g., block 1212) are further implemented by text correction module 600, including text boundary module 602, text correction model 604 or 700, and label application module 606. It would be clear to a person having ordinary skill in the art how other exemplary processes are implemented based on the components depicted in FIGS. 1A, 3, and 6-8.

In accordance with some implementations, a computer-readable storage medium (e.g., a non-transitory computer readable storage medium) is provided, the computer-readable storage medium storing one or more programs for execution by one or more processors of an electronic device, the one or more programs including instructions for performing any of the methods or processes described herein. Executable instructions for performing the techniques described herein are, optionally, included in a non-transitory computer-readable storage medium or other computer program product configured for execution by one or more processors. Executable instructions for performing these functions are, optionally, included in a transitory computer-readable storage medium or other computer program product configured for execution by one or more processors.

In accordance with some implementations, an electronic device (e.g., a portable electronic device) is provided that comprises means for performing any of the methods or processes described herein.

In accordance with some implementations, an electronic device (e.g., a portable electronic device) is provided that comprises a processing unit configured to perform any of the methods or processes described herein.

In accordance with some implementations, an electronic device e.g., a portable electronic device) is provided that comprises one or more processors and memory storing one or more programs for execution by the one or more processors, the one or more programs including instructions for performing any of the methods or processes described herein.

Some aspects of the present technology may include the gathering and use of data available from various sources to improve the accuracy and efficiency of automatic text correction. The present disclosure contemplates that in some instances, this gathered data may include personal information data that uniquely identifies or can be used to contact or locate a specific person. Such personal information data can include demographic data, location-based data, telephone numbers, email addresses, twitter IDs, home addresses, data or records relating to a user's health or level of fitness (e.g., vital signs measurements, medication information, exercise information), date of birth, or any other identifying or personal information.

The present disclosure recognizes that the use of such personal information data, in the present technology, can be used to the benefit of users. For example, the personal information data can be used to generate more relevant training data used to train text correction models. Accordingly, use of such personal information data enables more accurate and reliable automatic text correction using the trained text correction models. Further, other uses for personal information data that benefit the user are also contemplated by the present disclosure. For instance, health and fitness data may be used to provide insights into a user's general wellness, or may be used as positive feedback to individuals using technology to pursue wellness goals.

The present disclosure contemplates that the entities responsible for the collection, analysis, disclosure, transfer, storage, or other use of such personal information data will comply with well-established privacy policies and/or privacy practices. In particular, such entities should implement and consistently use privacy policies and practices that are generally recognized as meeting or exceeding industry or governmental requirements for maintaining personal information data private and secure. Such policies should be easily accessible by users, and should be updated as the collection and/or use of data changes. Personal information from users should be collected for legitimate and reasonable uses of the entity and not shared or sold outside of those legitimate uses. Further, such collection/sharing should occur after receiving the informed consent of the users. Additionally, such entities should consider taking any needed steps for safeguarding and securing access to such personal information data and ensuring that others with access to the personal information data adhere to their privacy policies and procedures. Further, such entities can subject themselves to evaluation by third parties to certify their adherence to widely accepted privacy policies and practices. In addition, policies and practices should be adapted for the particular types of personal information data being collected and/or accessed and adapted to applicable laws and standards, including jurisdiction-specific considerations. For instance, in the US, collection of or access to certain health data may be governed by federal and/or state laws, such as the Health Insurance Portability and Accountability Act (HIPAA); whereas health data in other countries may be subject to other regulations and policies and should be handled accordingly. Hence different privacy practices should be maintained for different personal data types in each country.

Despite the foregoing, the present disclosure also contemplates embodiments in which users selectively block the use of, or access to, personal information data. That is, the present disclosure contemplates that hardware and/or software elements can be provided to prevent or block access to such personal information data. For example, in the case of automatic text correction, the present technology can be configured to allow users to select to “opt in” or “opt out” of participation in the collection of personal information data during registration for services or anytime thereafter. In addition to providing “opt in” and “opt out” options, the present disclosure contemplates providing notifications relating to the access or use of personal information. For instance, a user may be notified upon downloading an app that their personal information data will be accessed and then reminded again just before personal information data is accessed by the app.

Moreover, it is the intent of the present disclosure that personal information data should be managed and handled in a way to minimize risks of unintentional or unauthorized access or use. Risk can be minimized by limiting the collection of data and deleting data once it is no longer needed. In addition, and when applicable, including in certain health related applications, data de-identification can be used to protect a user's privacy. De-identification may be facilitated, when appropriate, by removing specific identifiers (e.g., date of birth, etc.), controlling the amount or specificity of data stored (e.g., collecting location data at a city level rather than at an address level), controlling how data is stored (e.g., aggregating data across users), and/or other methods.

Therefore, although the present disclosure broadly covers use of personal information data to implement one or more various disclosed embodiments, the present disclosure also contemplates that the various embodiments can also be implemented without the need for accessing such personal information data. That is, the various embodiments of the present technology are not rendered inoperable due to the lack of all or a portion of such personal information data. For example, training data for text correction models can be generated based on non-personal information data or a bare minimum amount of personal information, such as the content being requested by the device associated with a user, other non-personal information available to the device, or publicly available information.

The foregoing description, for purpose of explanation, has been described with reference to specific embodiments. However, the illustrative discussions above are not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations are possible in view of the above teachings. The embodiments were chosen and described in order to best explain the principles of the techniques and their practical applications. Others skilled in the art are thereby enabled to best utilize the techniques and various embodiments with various modifications as are suited to the particular use contemplated.

Although the disclosure and examples have been fully described with reference to the accompanying drawings, it is to be noted that various changes and modifications will become apparent to those skilled in the art. Such changes and modifications are to be understood as being included within the scope of the disclosure and examples as defined by the claims. 

What is claimed is:
 1. A non-transitory computer-readable storage medium storing one or more programs configured to be executed by one or more processors of an electronic device with a display, the one or more programs including instructions for: receiving text input; in response to receiving the text input, displaying, on the display, a text string corresponding to the text input, wherein the text string is represented by a token sequence; determining whether an end of the token sequence corresponds to a text boundary; in accordance with a determination that the end of the token sequence corresponds to a text boundary: identifying, based on a context state of the token sequence, a textual error of a first type at two or more tokens of the token sequence, wherein identifying the textual error of the first type includes: determining, based on the context state of the token sequence, a sequence of labels to assign to the token sequence, wherein: a first label of the sequence of labels defines a start of a segment of two or more tokens of the token sequence; a second label of the sequence of labels defines an end of the segment of two or more tokens of the token sequence; and the first label and the second label indicate the first type of textual error and correspond to a first edit operation to perform on the segment of two or more tokens of the token sequence; and displaying, on the display, an error indication for a portion of the text string corresponding to the segment of two or more tokens; and applying the first edit operation and the second edit operation to the segment of two or more tokens to generate corrected text for the portion of the text string.
 2. The computer-readable storage medium of claim 1, wherein the textual error of the first type is identified based on a backward context state of the segment of two or more tokens and a forward context state of the segment of two or more tokens.
 3. The computer-readable storage medium of claim 1, wherein the context state is based on the entire token sequence.
 4. The computer-readable storage medium of claim 1, wherein the first edit operation is selected from a plurality of predefined edit operations.
 5. The computer-readable storage medium of claim 1, wherein the corrected text is associated with a confidence measure, and wherein the one or more programs further include instructions for: in accordance with the confidence measure satisfying a predefined condition, automatically replacing the displayed portion of the text string with the corrected text.
 6. The computer-readable storage medium of claim 1, wherein the one or more programs further include instructions for: receiving user input selecting the displayed error indication for the portion of the text string; and in response to receiving the user input, displaying the corrected text for user selection.
 7. The computer-readable storage medium of claim 6, wherein the one or more programs further include instructions for: in response to detecting a user selection of the displayed corrected text, replacing the displayed portion of the text string with the corrected text.
 8. The computer-readable storage medium of claim 1, wherein the one or more programs further include instructions for: determining a vector representation for the token sequence, wherein determining the sequence of labels is further based on the vector representation.
 9. The computer-readable storage medium of claim 1, wherein determining the sequence of labels further comprises: selecting each label of the sequence of labels from a plurality of predefined labels.
 10. The computer-readable storage medium of claim 9, wherein the one or more programs further include instructions for: determining, for a label of the sequence of labels, a probability for assigning the label to a token of the token sequence, and wherein the label is selected from the plurality of predefined labels based on the probability.
 11. The computer-readable storage medium of claim 1, wherein determining the sequence of labels includes assigning each token in the token sequence with a respective label of the sequence of labels.
 12. The computer-readable storage medium of claim 1, wherein the sequence of labels includes a label indicating that no edit operations are to be performed on an associated token of the token sequence.
 13. The computer-readable storage medium of claim 1, wherein the first edit operation is a replacement edit operation for replacing a token of the two or more tokens with a different token.
 14. The computer-readable storage medium of claim 1, wherein the first edit operation is an insert edit operation for inserting a new token before or after a token of the two or more tokens.
 15. The computer-readable storage medium of claim 1, wherein the first edit operation is a deletion edit operation for deleting a token of the two or more tokens.
 16. The computer-readable storage medium of claim 1, wherein determining the sequence of labels further comprises: determining a context-dependent feature vector of a current token in the token sequence based on a current backward context state of the current token and a current forward context state of the current token; determining, based on the context-dependent feature vector of the current token, a plurality of probabilities associated with a plurality of predefined labels; and based on the plurality of probabilities, selecting, from the plurality of predefined labels, a label to assign to the current token.
 17. The computer-readable storage medium of claim 1, wherein applying the first edit operation to the two or more tokens to generate corrected text for the portion of the text string is performed in response to determining the sequence of labels to assign to the token sequence.
 18. The computer-readable storage medium of claim 1, wherein determining whether the end of the token sequence corresponds to a text boundary includes determining whether the token sequence ended by the text boundary forms a complete linguistic unit.
 19. A method for text correction, comprising: at an electronic device having one or more processors, memory, and a display: receiving text input; in response to receiving the text input, displaying, on the display, a text string corresponding to the text input, wherein the text string is represented by a token sequence; determining whether an end of the token sequence corresponds to a text boundary; and in accordance with a determination that the end of the token sequence corresponds to a text boundary: identifying, based on a context state of the token sequence, a textual error of a first type at two or more tokens of the token sequence, wherein identifying the textual error of the first type includes: determining, based on the context state of the token sequence, a sequence of labels to assign to the token sequence, wherein:  a first label of the sequence of labels defines a start of a segment of two or more tokens of the token sequence;  a second label of the sequence of labels defines an end of the segment of two or more tokens of the token sequence; and  the first label and the second label indicate the first type of textual error and correspond to a first edit operation to perform on the segment of two or more tokens of the token sequence; and displaying, on the display, an error indication for a portion of the text string corresponding to the segment of two or more tokens; and applying the first edit operation to the segment of two or more tokens to generate corrected text for the portion of the text string.
 20. The method of claim 19, wherein the textual error of the first type is identified based on a backward context state of the segment of two or more tokens and a forward context state of the segment of two or more tokens.
 21. The method of claim 19, wherein the context state is based on the entire token sequence.
 22. The method of claim 19, wherein the first edit operation is selected from a plurality of predefined edit operations.
 23. The method of claim 19, wherein the corrected text is associated with a confidence measure, and further comprising: in accordance with the confidence measure satisfying a predefined condition, automatically replacing the displayed portion of the text string with the corrected text.
 24. The method of claim 19, further comprising: receiving user input selecting the displayed error indication for the portion of the text string; and in response to receiving the user input, displaying the corrected text for user selection.
 25. The method of claim 24, further comprising: in response to detecting a user selection of the displayed corrected text, replacing the displayed portion of the text string with the corrected text.
 26. The method of claim 19, further comprising: determining a vector representation for the token sequence, wherein determining the sequence of labels is further based on the vector representation.
 27. The method of claim 19, wherein determining the sequence of labels further comprises: selecting each label of the sequence of labels from a plurality of predefined labels.
 28. The method of claim 27, further comprising: determining, for a label of the sequence of labels, a probability for assigning the label to a token of the token sequence, and wherein the label is selected from the plurality of predefined labels based on the probability.
 29. The method of claim 19, wherein determining the sequence of labels includes assigning each token in the token sequence with a respective label of the sequence of labels.
 30. The method of claim 19, wherein the sequence of labels includes a label indicating that no edit operations are to be performed on an associated token of the token sequence.
 31. The method of claim 19, wherein the first edit operation is a replacement edit operation for replacing a token of the two or more tokens with a different token.
 32. The method of claim 19, wherein the first edit operation is an insert edit operation for inserting a new token before or after a token of the two or more tokens.
 33. The method of claim 19, wherein the first edit operation is a deletion edit operation for deleting a token of the two or more tokens.
 34. The method of claim 19, wherein determining the sequence of labels further comprises: determining a context-dependent feature vector of a current token in the token sequence based on a current backward context state of the current token and a current forward context state of the current token; determining, based on the context-dependent feature vector of the current token, a plurality of probabilities associated with a plurality of predefined labels; and based on the plurality of probabilities, selecting, from the plurality of predefined labels, a label to assign to the current token.
 35. The method of claim 19, wherein applying the first edit operation to the two or more tokens to generate corrected text for the portion of the text string is performed in response to determining the sequence of labels to assign to the token sequence.
 36. The method of claim 19, wherein determining whether the end of the token sequence corresponds to a text boundary includes determining whether the token sequence ended by the text boundary forms a complete linguistic unit.
 37. An electronic device, comprising: a display; one or more processors; and memory storing one or more programs configured to be executed by the one or more processors, the one or more programs including instructions for: receiving text input; in response to receiving the text input, displaying, on the display, a text string corresponding to the text input, wherein the text string is represented by a token sequence; determining whether an end of the token sequence corresponds to a text boundary; and in accordance with a determination that the end of the token sequence corresponds to a text boundary: identifying, based on a context state of the token sequence, a textual error of a first type at two or more tokens of the token sequence, wherein identifying the textual error of the first type includes: determining, based on the context state of the token sequence, a sequence of labels to assign to the token sequence, wherein:  a first label of the sequence of labels defines a start of a segment of two or more tokens of the token sequence;  a second label of the sequence of labels defines an end of the segment of two or more tokens of the token sequence; and  the first label and the second label indicate the first type of textual error and correspond to a first edit operation to perform on the segment of two or more tokens of the token sequence; and displaying, on the display, an error indication for a portion of the text string corresponding to the segment of two or more tokens; and applying the first edit operation to the segment of two or more tokens to generate corrected text for the portion of the text string.
 38. The electronic device of claim 37, wherein the textual error of the first type is identified based on a backward context state of the segment of two or more tokens and a forward context state of the segment of two or more tokens.
 39. The electronic device of claim 37, wherein the context state is based on the entire token sequence.
 40. The electronic device of claim 37, wherein the first edit operation is selected from a plurality of predefined edit operations.
 41. The electronic device of claim 37, wherein the corrected text is associated with a confidence measure, the one or more programs further including instructions for: in accordance with the confidence measure satisfying a predefined condition, automatically replacing the displayed portion of the text string with the corrected text.
 42. The electronic device of claim 37, the one or more programs further including instructions for: receiving user input selecting the displayed error indication for the portion of the text string; and in response to receiving the user input, displaying the corrected text for user selection.
 43. The electronic device of claim 42, the one or more programs further including instructions for: in response to detecting a user selection of the displayed corrected text, replacing the displayed portion of the text string with the corrected text.
 44. The electronic device of claim 37, the one or more programs further including instructions for: determining a vector representation for the token sequence, wherein determining the sequence of labels is further based on the vector representation.
 45. The electronic device of claim 37, wherein determining the sequence of labels further comprises: selecting each label of the sequence of labels from a plurality of predefined labels.
 46. The electronic device of claim 45, the one or more programs further including instructions for: determining, for a label of the sequence of labels, a probability for assigning the label to a token of the token sequence, and wherein the label is selected from the plurality of predefined labels based on the probability.
 47. The electronic device of claim 37, wherein determining the sequence of labels includes assigning each token in the token sequence with a respective label of the sequence of labels.
 48. The electronic device of claim 37, wherein the sequence of labels includes a label indicating that no edit operations are to be performed on an associated token of the token sequence.
 49. The electronic device of claim 37, wherein the first edit operation is a replacement edit operation for replacing a token of the two or more tokens with a different token.
 50. The electronic device of claim 37, wherein the first edit operation is an insert edit operation for inserting a new token before or after a token of the two or more tokens.
 51. The electronic device of claim 37, wherein the first edit operation is a deletion edit operation for deleting a token of the two or more tokens.
 52. The electronic device of claim 37, wherein determining the sequence of labels further comprises: determining a context-dependent feature vector of a current token in the token sequence based on a current backward context state of the current token and a current forward context state of the current token; determining, based on the context-dependent feature vector of the current token, a plurality of probabilities associated with a plurality of predefined labels; and based on the plurality of probabilities, selecting, from the plurality of predefined labels, a label to assign to the current token.
 53. The electronic device of claim 37, wherein applying the first edit operation to the two or more tokens to generate corrected text for the portion of the text string is performed in response to determining the sequence of labels to assign to the token sequence.
 54. The electronic device of claim 37, wherein determining whether the end of the token sequence corresponds to a text boundary includes determining whether the token sequence ended by the text boundary forms a complete linguistic unit. 